您是否尝试无优先级地使用add\\u操作?在最后一行,指定优先级。较小的数字对应较早的执行,具有相同优先级的函数按照它们添加到操作的顺序执行。
function test_1234567() {
// Get term by name \'\'news\'\' in Categories taxonomy.
$category = get_term_by(\'name\', \'news\', \'category\');
// Get term by name \'\'news\'\' in Tags taxonomy.
$tag = get_term_by(\'name\', \'news\', \'post_tag\');
// Get term by name \'\'news\'\' in Custom taxonomy.
$term = get_term_by(\'name\', \'news\', \'my_custom_taxonomy\');
// Get term by name \'\'Default Menu\'\' from theme\'s nav menus.
// (Alternative to using wp_get_nav_menu_items)
$menu = get_term_by(\'name\', \'Default Menu\', \'nav_menu\');
var_dump($category);
}
add_action( \'init\', \'test_1234567\' );
此外,您不需要指定优先级,默认值为10。