如何在wordpress管理面板中更改元素的名称?例如,改变"帖子" on" Products",包含所有表格,随处可见。我知道,当我创建自己的分类法时,我可以设置它的所有形式的名称。也许我可以为帖子和页面等实体的一般名称制作类似的内容?
答案 0 :(得分:1)
您可以更改init
操作挂钩中的名称,如下所示:
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Products';
$labels->singular_name = 'Product';
$labels->add_new = 'Add Product';
$labels->add_new_item = 'Add Product';
$labels->edit_item = 'Edit Products';
$labels->new_item = 'Product';
$labels->view_item = 'View Product';
$labels->search_items = 'Search Products';
$labels->not_found = 'No Products found';
$labels->not_found_in_trash = 'No Products found in Trash';
}
add_action( 'init', 'change_post_object_label' );
要更改菜单标签,但必须使用单独的挂钩:admin_menu
function edit_menu_items() {
global $menu;
global $submenu;
$menu[5][0] = 'Products';
$submenu['edit.php'][5][0] = 'Products';
$submenu['edit.php'][10][0] = 'Add Product';
}
add_action('admin_menu', 'edit_menu_items');