Changing the Order of Admin Menu Sections?

I am getting a bit frustrated over here after having spent a few hours trying to accomplish this fairly simple task without any luck.

Essentially I have 5 custom post types which I created and all I want to do is show each of them in a specific order directly under the “dashboard”.

From the WordPress documentation it seems that you can’t really do this because the highest menu order seems to be “5”. And above

I am guessing some expert reading this can show me the simple way that I can order the admin menu exactly the way I want to by utilizing the functions file and without utilizing a plugin (which I know exists).

Please go ahead and try to create 5 separate post types and include them in a specific order directly under the dashboard… it seems this is not possible.??… is there some type of jquery hack to make this work that someone could share with me or preferably without utilizing jQuery?


Hi @BinaryBit:

It’s no wonder you are a bit frustrated; the admin menu is one of the most obtuse and frustrating implementations through WordPress core. Honestly, I don’t know what they were thinking when they designed it that way.

@EAMann did an excellent job of explaining how the admin menus work in WordPress (I wish I had been able to read that about 4 months ago… 🙂

Still, after I figured it out how it worked I was still at a loss to work with it without devoting enough time to keep my head straight while I tried to do simple things. So that’s why I built a Menu API that simplifies and streamlines working with the WordPress admin menu.

They are 100% compatible with WordPress’ existing structures and still very much in alpha since I’ve been the only one using it. I’m sure there are use-cases they do not yet handle. But I’ll post the code here for you and others to try out.

You can download the file to drop in your theme’s directory here: wp-admin-menu-classes.php and what follows shows how you might call the functions in your theme’s functions.php file:

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.
  add_admin_menu_item('Movies',$movie_tags_item_array,array(// Add Back the Movie Tags at the end.
  delete_admin_menu_section('Actors');                      // Finally just get rid of the actors section

What’s more, these functions are even under consideration (as a base) for inclusion in WordPress 3.1 so if we’re lucky these might even become standard!

Leave a Comment