Removing Menu Item in WordPress Admin Panel

WordPress Admin Panel comes with lot of options in menu, but sometimes you may need to get rid of some menu item (your client may ask you for this or any other possible situation ). In following post, i will explain the procedure for getting rid of menu item from wordpress admin panel menu. For sake of example, i will be removing “Posts Section” from menu.

wordpress-remove-menu-item-admin-panel-shumailmohyuddin-com

To achieve this, we will edit wordpress theme’s function.php and add some code there. This section of posts lies as edit.php.

Official WordPress API has remove_menu_page() function & Documentation states function usage as:


<?php remove_menu_page( $menu_slug ) ?>

Here $menu_slug is edit.php for post menu.

Now create your own function called post_remove() and add code in functions.php as:


function post_remove ()
{
    remove_menu_page('edit.php');
}
//your custom function - post_remove() - for removing menu item

The next part is to hook your post_remove() function with a specific action which in this case is admin_menu to trigger this function. For that, add some more code in functions.php:


add_action('admin_menu', 'post_remove');
//creating action to trigger function call

So in short, following is complete code that you need to add in your functions.php file:


function post_remove () //creating functions post_remove for removing menu item
{
    remove_menu_page('edit.php');
}

add_action('admin_menu', 'post_remove'); //adding action for triggering function call

The code above will get rid of the Posts option for all users. I only removed Posts option for example in tutorial but you can use this method and code snippet to remove any section you want from wordpress Admin Panel menu using it’s  $menu_slug.

Official documentation links

http://codex.wordpress.org/Function_Reference/remove_menu_page http://codex.wordpress.org/Function_Reference/add_action

Share your thoughts in comments below or if you face any issue, do let me know – Don’t forget to share this article – Sharing is Caring..

2 thoughts on “Removing Menu Item in WordPress Admin Panel

  1. This is a nice article.

    Can you write an article on limiting different user options. For example if we have different users on our wordpress website, and we can hide specific menu from certain users not all.? Can we do that?

Leave a Reply