WordPress后台菜单重命名

后台管理菜单名称重命名的方法

主题的functions.php 文件下加入以下代码:

  1. function change_post_menu_label() {
  2.     global $menu;
  3.     global $submenu;
  4.     $menu[5][0] = 'Contacts';
  5.     $submenu['edit.php'][5][0] = 'Contacts';
  6.     $submenu['edit.php'][10][0] = 'Add Contacts';
  7.     $submenu['edit.php'][15][0] = 'Status'; // Change name for categories
  8.     $submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
  9.     echo '';
  10. }
  11.  
  12. function change_post_object_label() {
  13.         global $wp_post_types;
  14.         $labels = &$wp_post_types['post']->labels;
  15.         $labels->name = 'Contacts';
  16.         $labels->singular_name = 'Contact';
  17.         $labels->add_new = 'Add Contact';
  18.         $labels->add_new_item = 'Add Contact';
  19.         $labels->edit_item = 'Edit Contacts';
  20.         $labels->new_item = 'Contact';
  21.         $labels->view_item = 'View Contact';
  22.         $labels->search_items = 'Search Contacts';
  23.         $labels->not_found = 'No Contacts found';
  24.         $labels->not_found_in_trash = 'No Contacts found in Trash';
  25.     }
  26.     add_action( 'init', 'change_post_object_label' );
  27.     add_action( 'admin_menu', 'change_post_menu_label' );

该代码就是把原来的文章post的菜单名“post”更改为Contact。

原文阅读


发布日期:

所属分类: Wordpress 综合 标签: