Want to remove some of the root WordPress Admin sidebar navigation?

  1. Home
  2. Knowledge Base
  3. WP Techniques
  4. Want to remove some of the root WordPress Admin sidebar navigation?

We have a client that was mainly interested in writing pages and managing media for those pages, they were not going to use Posts, Comments or Links in the administration area. We set them up as Editors on a WordPress Multisite installation, below is how we removed those items from appearing in the navigation.

First we define a new function, we used remove_admin_menu_items(). In this function we define an array $remove_menu_items that contains the menu items we wish to remove from the admin navigation. The function is designed to step through WordPress multidimensional array $menu, getting each $menu item name by use of the PHP function explode(). It then checks if that $menu item name is in our $remove_menu_items array using the PHP function in_array(). If the $menu item name does appear, then that item is removed from the multidimensional array $menu, by use the PHP function unset().

We then initiate the remove_admin_menu_items() function using the add_action() WordPress function as shown below.

Putting it all together yields the following code to be placed in your themes functions.php file:

All youll need to change is the array of items to remove in the $remove_menu_items array. In our example we removed: Posts, Links and Comments. Other root level WordPress admin sidebar navigation items available for removal are Media, Pages, Appearance, Plugins, Users, Tools and Settings.

Was this article helpful?

Related Articles

Leave a Reply