In this post, I am going to show how you can easily remove menus and submenu links from WordPress dashboard, and also how to order them in the way you want in WordPress 3.1.
Remove Menu Page Links
WordPress 3.1 comes with a built-in function that allows quick and easy removal of any of the default menus from the dashboard.
This is the complete list of default menu pages:
function delete_menu_items() { remove_menu_page('index.php'); // Dashboard remove_menu_page('edit.php'); // Posts remove_menu_page('upload.php'); // Media remove_menu_page('link-manager.php'); // Links remove_menu_page('edit.php?post_type=page'); // Pages remove_menu_page('edit-comments.php'); // Comments remove_menu_page('themes.php'); // Appearance remove_menu_page('plugins.php'); // Plugins remove_menu_page('users.php'); // Users remove_menu_page('tools.php'); // Tools remove_menu_page('options-general.php'); // Settings } add_action( 'admin_init', 'delete_menu_items' );
Keep the one’s you want to remove and add the code to the theme’s functions.php
file.
Remove Menu Page Links Based on Roles
You can also remove menu pages for users based on roles. The below code will remove the Tools and Settings links only for Editors:
function delete_menu_items() { if ( current_user_can( 'editor' )) { remove_menu_page('tools.php'); // Tools remove_menu_page('options-general.php'); // Settings } } add_action( 'admin_init', 'delete_menu_items' );
Remove Submenu Page Links
WordPress also lets you remove submenu links from a menu.
To remove a submenu page, you need to include both the menu and submenu slug in the function.
Below code will remove the Widgets and theme Editor link, found under theĀ Appearance menu. You can get a preview of it in the above image.
function delete_submenu_items() { remove_submenu_page( 'themes.php', 'widgets.php' ); remove_submenu_page( 'themes.php', 'theme-editor.php'); } add_action( 'admin_init', 'delete_submenu_items' );
Remove Submenu Page Links Based on Roles
Submenus can also be removed based on user role. This will remove the theme Editor link only for Editors.
function delete_submenu_items() { if ( current_user_can( 'editor' )) { remove_submenu_page( 'themes.php', 'theme-editor.php'); } } add_action( 'admin_init', 'delete_submenu_items' );
Reorder Menu Links
Now that you only have the links you need in the menu, they can also be ordered the way you want.
This is the default order of menu links:
function custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // Dashboard 'edit.php', // Posts 'upload.php', // Media 'link-manager.php', // Links 'edit.php?post_type=page', // Pages 'edit-comments.php', // Comments 'themes.php', // Appearance 'plugins.php', // Plugins 'users.php', // Users 'tools.php', // Tools 'options-general.php' // Settings ); } add_filter('custom_menu_order', 'custom_menu_order'); add_filter('menu_order', 'custom_menu_order');
Organize the menu in the order you want and add the code to your theme’s functions.php
file. Don’t add those menu links which you don’t want to order. They will still appear but as per the default layout.
9 thoughts on “Remove and Reorder Menu/Submenu Links in WordPress Dashboard”
Hi, thanks for the info. I was wondering if it was possible to move the Appearance > Menus to Pages > Menus ?
This is great, but when I have it set to affect the editor role, it’s still removing the sub-menu for my network admin account. I’m running WP 3.2.
Thanks.
Thanks for this tip. Now, I can hide unwanted menu links from dashboard.
Brilliant hack this, just wanted to ask a quick question
Is it possible to remove a certain page,
ie I have a page like this admin.php?page=custom-contact-forms
But tried to remove but wouldn`t remove this plugin admin
Hey there. Great tutorial, thank you.
I tried implementing the re-ordering part of the tutorial, using the below code:
I was trying to only invoke the reordering for non-Admin users. It works, but unfortunately I now get an error text line at the top of the Dashboard when I login as Admin. The error says “Warning: array_flip() expects parameter 1 to be array, null given in C:\xampp\htdocs\wordpress\wp-admin\includes\menu.php on line 193”
Clearly my if statement needs some work…would love some advice here.
Ah brilliant, I got it working in the end. Logic told me I needed the if statement around the add_filter, and it worked. See here –> http://pastebin.com/MFYQAiZP
Thank you so much! This tutorial is so awesome ! I searched for my problem (reordering menu items) for so long. And now I found this great solution! THANKS SO MUCH!
thank you very much renji.i wasted hours before this.you are awesome.nicely described.
It doesnt’ work for comments…