摘要:上一篇文章大挖讲了如何隐藏或是删除wordpress主题后台默认的菜单选项,那今天这篇文章给大家讲一下如何重命名word…
上一篇文章大挖讲了如何隐藏或是删除wordpress主题后台默认的菜单选项,那今天这篇文章给大家讲一下如何重命名wordpress后台默的认菜单选项,这个使用场景通常出现在一些企业主题或是小众的主题中,我们需要把wordpress默认的一些文章修改为网站导航或是发表小说,或是发表新闻等等,用户提示企业客户更好的增强用户使用体验,在wordpress主题开发中也有着不错的优化效果,那我们如何进行修改呢?
方法很简单,同样是把代码添加到functions.php 文件下。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = ‘Contacts’;
$submenu[‘edit.php’][5][0] = ‘Contacts’;
$submenu[‘edit.php’][10][0] = ‘Add Contacts’;
$submenu[‘edit.php’][15][0] = ‘Status’; // Change name for categories
$submenu[‘edit.php’][16][0] = ‘Labels’; // Change name for tags
echo ”;
}
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types[‘post’]->labels;
$labels->name = ‘Contacts’;
$labels->singular_name = ‘Contact’;
$labels->add_new = ‘Add Contact’;
$labels->add_new_item = ‘Add Contact’;
$labels->edit_item = ‘Edit Contacts’;
$labels->new_item = ‘Contact’;
$labels->view_item = ‘View Contact’;
$labels->search_items = ‘Search Contacts’;
$labels->not_found = ‘No Contacts found’;
$labels->not_found_in_trash = ‘No Contacts found in Trash’;
}
add_action( ‘init’, ‘change_post_object_label’ );
add_action( ‘admin_menu’, ‘change_post_menu_label’ );
|
以上的代码是把原来的文章post的菜单名“post”更改为Contact。大家可以结合咱们的中文内容进行调整。
来源:http://www.wazhuti.com/1797.html