Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to customize the admin area using the functions.php file to make things easier for my clients. One request I have got before and hope to be able to accomplish, is to move some of the sub menus into the main navigation.

For instance I would like to make Widgets and Menus appear in the main navigation as opposed to being a submenu for Appearances. I would then end up removing the Appearances tab all together.

I have been able to remove the tab but unable to make the new buttons for Widgets and Menus. Even if I can get help of not technically moving them but instead creating a new button and setting the link myself (ex. for Menus -> /nav-menus.php).

Is any of that possible?

Thanks

share|improve this question
1  
Mike once wrote a great menu API layer, perhaps the functions you need are already included there? –  Jan Fabry Feb 13 '11 at 16:52
    
@Jan: Wow! A great link and a good read. Even if this doesn't make it into 3.1, this is an excellent tool. –  Peter Rowell Feb 13 '11 at 20:14
add comment

3 Answers

up vote 1 down vote accepted

OK, it's a bit messy, but it works. Take a look

function remove_submenus() {
  global $submenu;
  unset($submenu['themes.php'][10]); // Removes Menu  
}
add_action('admin_menu', 'remove_submenus');



function new_nav_menu () {
    global $menu;
    $menu[99] = array('', 'read', 'separator', '', 'menu-top menu-nav');
    add_menu_page(__('Nav Menus', 'mav-menus'), __('Nav Menus', 'nav-menus'), 'edit_themes', 'nav-menus.php', '', 99);
}
add_action('admin_menu', 'new_nav_menu');

Essentially it is removing the nav menu settings from the Appearance sub-panel, then re-adding it as a top level page (similar to a plugin). You can set an icon URL in there as well. The only part I can't get working the way I want is the positioning.

share|improve this answer
    
Thank you, this is exactly what I had in mind! –  Adam Feb 15 '11 at 18:22
add comment

You can change the order by using the menu_order filter:

function custom_menu_order($menu_ord) {  
if (!$menu_ord) return true;  

return array(  
    'index.php', // Dashboard  
    'edit.php', // Posts 
    'upload.php', // Media
    'edit.php?post_type=page', // Pages
    'edit-comments.php', // Comments 
    'link-manager.php', // Links 
    'separator1', // First separator  
    'nav-menus.php', // Navigation
    'separator2', // Second separator  
    'themes.php', // Appearance  
    'plugins.php', // Plugins  
    'users.php', // Users  
    'tools.php', // Tools  
    'options-general.php', // Settings  
    'separator-last', // Last separator  
);
}  
add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order  
add_filter('menu_order', 'custom_menu_order');

This was taken from this article here: customizing your wordpress admin

Notice that the nav-menu.php has been added to the top level menu. To re-position each menu item just rearrange them.

share|improve this answer
    
Have you tested this code? Ain't working on my side... WordPress 3.4.2 and 3.5-beta2 –  brasofilo Oct 20 '12 at 2:46
add comment

Good article on this, old link that can help with this, http://wpengineer.com/475/top-level-menu-in-wordpress-27/

Also, the solution that @Norcross is proposing works great, but the icon 99 will throw an error, you could leave it blank, eg. '' instead of 99. You could also have your own custom icon using basename(__FILE__) and the filename.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.