WordPress 内容类型名称重命名方法

王朝学院·作者佚名  2016-08-22
窄屏简体版  字體: 小  |  中  |  大  |  超大  

WordPRess系统源于一个blog平台,慢慢地发展到今天的这样一个功能强大的cms系统!

尽管如此,但是wordpress默认情况下文章页英文叫post, page,有时候,我们开发的时候,也许并不想要这个菜单还是显示着post,和page,也许你想要显示为其它的名称,比如“产品”,”联系人”亦或是其它的名称!

当然我们可以自己写一个post type,移除原来的文章类型,新建的的内容类型可以自己命名,但是其实我们还有一个更好的方法对原来系统的内容类型菜单名称进行重命名:

看下面的一个国外的高手的代码:

<?phpfunctionchange_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 tagsecho'';}functionchange_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');To change the menu order,go with this:// CUSTOMIZE ADMIN MENU ORDERfunctioncustom_menu_order($menu_ord){if(!$menu_ord)returntrue;returnarray('index.php',// this represents the dashboard link'edit.php',//the posts tab'upload.php',// the media manager'edit.php?post_type=page',//the posts tab);}add_filter('custom_menu_order','custom_menu_order');add_filter('menu_order','custom_menu_order');?>

这一个代码中就是把原来的文章post的菜单名“post”更改为Contact了!

参考资料:http://wordpress.stackexchange.com/questions/9211/changing-admin-menu-labels

原文地址:http://markchen.me/the-wordpress-menu-name-rename/

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航