0

我想在我的 wordpress 管理仪表板中重新排列菜单顺序并尝试了以下代码。但未能成功。在我使用的代码下方。我在functions.php 页面中使用了它们。

function enable_custom_menu_order() {
return true;
    }

function custom_menu_order() {
//return array('edit.php','shashopping.php', 'edit-comments.php','index.php' );
return array( 
'admin.php?page=my_plugin_page.php',    //my plugin page
'tools.php', // Tools  
    'index.php', // Dashboard
    'separator1', // First separator
    'admin.php',
    'edit.php', // Posts  
    'upload.php', // Media  
    'link-manager.php', // Links  
    'edit.php?post_type=page', // Pages  
    'edit-comments.php', // Comments  
    'separator2', // Second separator  
    'themes.php', // Appearance  
    'plugins.php', // Plugins  
    'users.php', // Users
    'options-general.php', // Settings  
    'separator-last', // Last separator  

  );  
  }

 add_filter( 'custom_menu_order', 'enable_custom_menu_order' );
 add_filter( 'menu_order', 'custom_menu_order' );
4

1 回答 1

2

在此处下载文件以放入您的主题目录:wp-admin-menu-classes.php,然后您可以调用主题functions.php文件中的函数:

 <?php
    require_once('wp-admin-menu-classes.php');
    add_action('admin_menu','my_admin_menu');
    function my_admin_menu() {
      swap_admin_menu_sections('Pages','Posts');              // Swap location of Posts Section with Pages Section
      rename_admin_menu_section('Media','Photos & Video');    // Rename Media Section to "Photos & Video"
      delete_admin_menu_section('Links');                     // Get rid of Links Section
      $movie_tags_item_array = get_admin_menu_item_array('Movies','Movie Tags');  // Save off the Movie Tags Menu
      update_admin_menu_section('Movies',array(               // Rename two Movie Menu Items and Delete the Movie Tags Item
        array('rename-item','item'=>'Movies','new_title'=>'List Movies'),
        array('rename-item','item'=>'Add New','new_title'=>'Add Movie'),
        array('delete-item','item'=>'Movie Tags'),
      ));
      copy_admin_menu_item('Movies',array('Actors','Add New')); // Copy the 'Add New' over from Actors
      renamed_admin_menu_item('Movies','Add New','Add Actor');  // Rename copied Actor 'Add New' to 'Add Actor
      add_admin_menu_item('Movies',array(                       // (Another way to get a 'Add Actor' Link to a section.)
        'title' => 'Alt Add Actor ',
        'slug' => 'post-new.php?post_type=actor',
      ), array(// Add Back the Movie Tags at the end.
        'where'=>'end'
      ));
      add_admin_menu_item('Movies',$movie_tags_item_array,array(// Add Back the Movie Tags at the end.
        'where'=>'end'
      ));
      delete_admin_menu_section('Actors');                      // Finally just get rid of the actors section
    }

或者

试试这个 wordpress 插件

http://wordpress.org/plugins/admin-menu-editor/

工作插件快照

于 2013-09-10T11:17:16.883 回答