Removing WordPress Admin Menus

Written by on December 29, 2010 in WordPress Tutorials - 5 Comments

When deploying WordPress sites for clients, it can be extremely useful to customize aspects of the WordPress admin area. For users who are not familiar with WordPress, some aspects of the admin area can be confusing, especially if they are not being directly utilized by the client. For example, not all users need a Links section for their site (perhaps less is more if you are designing a site for a client using WordPress). So here’s a quick tip for removing menu items from the main admin navigation.

Simply paste this into your functions.php:

// function to remove the Links menu item
function remove_menus()
{
	// setup the global menu variable
	global $menu;
	// this is an array of the menu item names we wish to remove
	$restricted = array( __('Links'),__('Tools'),__('Settings'),__('Comments'));
	end ($menu);
 
	while (prev($menu))
	{
		$value = explode(' ',$menu[key($menu)][0]);
 
		if(in_array($value[0] != NULL?$value[0]:"" , $restricted))
		{
			unset($menu[key($menu)]);
		}
	}
}
// hook into the action that creates the menu
add_action('admin_menu', 'remove_menus');

This code will remove the Links, Tools, Settings, and Comments menu items. Simply add all the menu names you wish to remove to this part of the code above:

$restricted = array( __('Links'),__('Tools'),__('Settings'),__('Comments'));

So what would it look like if you wanted to remove the Tools, Comments, Appearance, Plugins, and Settings menus? The complete code is this:

// function to remove the Links menu item
function remove_menus()
{
	// setup the global menu variable
	global $menu;
	// this is an array of the menu item names we wish to remove
	$restricted = array( __('Tools'),__('Comments'),__('Appearance'),__('Plugins'),__('Settings'));
	end ($menu);
 
	while (prev($menu))
	{
		$value = explode(' ',$menu[key($menu)][0]);
 
		if(in_array($value[0] != NULL?$value[0]:"" , $restricted))
		{
			unset($menu[key($menu)]);
		}
	}
}
// hook into the action that creates the menu
add_action('admin_menu', 'remove_menus');

I hope you found this article useful. If you are unsure about anything please let me know :)

Pippin

About

Pippin Williamson is an expert WordPress dev with 4+ years of experience. You may follow him on Twitter @pippinspages and @pippinsplugins and see his free WP plugins, themes, and tutorials he has to offer at Pippin's Pages.com and Pippin's Plugins.com

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

WordPress is a fantastic blogging tool and publishing platform, but is it optimised out of the box for Search Engine Optimisation (SEO)? Well, despite the fact that the search engines tend to love websites built on the WordPress platform, it isn't particularly well optimised with a default installation. In the default WordPress installation, it does not include meta tags such as meta description and meta keywords. If you want to supply search engines with specific information, relevant to your websites pages, you are going to have to add the meta tag data yourself.

What about removing menu items added by themes and plugins? I'm trying this, but apparently the name I'm using for the certain menu item is just a menu title, not a menu name. How to you find the menu name?

Thanks! This is exactly what I was looking for :)

kindly mention where this function is to be declared ,, and from where i have to call that function ,,,

Paste the function into the functions.php file inside your theme directory. You do not need to call the function from anywhere, just include it in functions.php.