在现有的定制分类法上重命名您想要的所有内容非常容易.
您可以首先使用get_taxonomy()
WordPress function可视化要重命名的分类数据.以下内容显示在前端页脚中,其中包含您的分类(only visible for admins)的所有数据:
add_action('wp_footer', 'wp_footer_script_test_output', 10);
function wp_footer_script_test_output() {
if( ! current_user_can('administrator') ) return;
echo '<pre>'. print_r( get_taxonomy('video-director'), true ) . '</pre>';
}
现在,您可以看到可以重命名的所有数据.一旦完成,您就可以删除该代码.
下面将根据您的代码重命名位于管理菜单(and optionally some other labels that you can remove)中的分类标签:
function overwrite_director_slug( $taxonomy, $object_type, $args ){
if( 'video-director' == $taxonomy ){
remove_action( current_action(), __FUNCTION__ );
$args['rewrite'] = array('slug' => 'instructor');
$args['labels']->menu_name = 'Instructor'; // <=== HERE For the "MENU NAME"
$args['labels']->singular_name = 'Instructor'; // (optional)
$args['labels']->name = 'Instructor'; // (optional)
$args['label'] = 'Instructor'; // General label (optional)
register_taxonomy( $taxonomy, $object_type, $args );
}
}
add_action( 'registered_taxonomy', 'overwrite_director_slug', 10, 3 );
代码位于您的子主题的unctions.php文件中(或在插件中).经过测试和工作.