Remove specific menu items from the WordPress Admin

Sometimes it’s best – especially when you’re using WordPress as a CMS – to remove those unwanted admin menus that create clutter for clients. They are never going to use them so why confuse their admin experience? For example: if the client isn’t going to blog, why include Posts or Comments in the menu at all?

Just insert this code into the functions.php file of your WordPress theme and *bam!* no more clutter. Please note that we are not going to restrict the Administrator user experience, this will just affect logged in users who can’t manage options.

(Make sure to edit the $restricted array with the items you want to hide, this is just an example so you can see what’s possible) Enjoy!

4 Comments

Add yours →

  1. Just thought you should know that this does not work. Also, not all menu items are just one word, so how to list if the menu item has two or more words? With just a space… or, with a dash – , or with an underscore _ ? For example to hide the “Revolution Slider” from the Admin menu should it be ‘menu-revolution slider’, ‘menu-revolution-slider’, or ‘menu-revolution_slider’? I’ve tried all, though – and nothing works.

    • Hello, Vee. Thank you for your comment.

      1) Please note line 11 in the code. This script will not remove any menu items for users who have the manage_options capability, like Administrators. Be sure to login and check with a user assigned to the “Editor” role.

      2) The list of slugs in the $restricted array are referring to the menu item ID. Inspect the source of your WP Admin area and search for “menu-posts”, you will see that this is the ID of the <li> element for the “Posts” menu item.

      The ID has nothing to do with the actual title of the menu item (e.g. Posts, Comments, etc). Go take a look at the add_menu_page() function and check out the forth parameter called $menu_slug. This is what is used as the ID when registering a new Admin page, it’s a required parameter, so there will always be one.

Leave a Reply

%d bloggers like this: