As a WordPress developer, I often find myself tasked with building very specific WP themes. So specific in fact, that I end up leaving out a lot of the default functionality. The problem is, I want the client to have a seamless experience while dealing with the back-end of their site. I don’t want them wondering what the Comments tab does, or why the Posts tab brings them to an empty list, because maybe their site didn’t require those options.
So, what to do? Well, hide them. Hiding unused menu tabs is a quick and easy way to de-clutter the back-end of your WordPress site. WordPress 3.1.0 introduced two new ways of doing this: remove_menu_page and remove_submenu_page.
The example below shows how you would remove the Comments menu item, by pasting this code in your functions.php file:
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
// the parameter is the slug of the menu item to be removed
remove_menu_page(‘edit-comments.php’);
}
But what if you want to remove more than just the comments? That the easy part, just call remove_menu_page() again, inside the function, passing the menu item’s slug as the main parameter.
That works great for top-level menu items, but what if we want to remove sub-menu items? That’s where remove_submenu_page() comes in. The example below shows how you would remove the Editor sub-menu item, by pasting this code in your functions.php file:
add_action( 'admin_menu', 'my_remove_sub_menu_pages' );
function my_ remove_sub _menu_pages() {
// the first parameter is the slug of the top menu item to be removed
// the second parameter is the slug of the sub-menu item
remove_submenu_page( 'themes.php', 'theme-editor.php' );
}
Again, you can call this as many times as you’d like, to remove even more sub-menu items.
Aaron
Hey Justin, I had the same problem with the client sites I’ve been building so I whipped up a very basic plugin to help keep the admin minimal for ‘editors’ http://wordpress.org/extend/plugins/minimal-admin/
Justin Rhodes
Hey Aaron, I like that you’re hiding the Dashboard (very seldom used for most clients), nice plugin!
Fatoumata
That is a slick piece of code. I sometimes hate that you are stuck with most theme temlpates for the entire site. Not only is the code cool, but I am getting all sorts of new ideas of how I can use it to change up my blog based on the categories. Will be giving it a go, thanks for sharing!
Alex
I’ve tried the remove theme-editor, and it is simply not working. I’ve managed to remove themes.php however not the editor. Please advise?
Alex
http://wordpress.org/support/topic/how-to-remove-theme-editor-submenu
fix to the problem - use admin_init, instead of admin_menu
Matt
Thanks for the great post. And thank you Alex for the great tip/update. Perfect combo. Cheers!