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..

WordPress: Change Color of specific menu Tab in Navigation menu

Complexity: A recent problem i faced was to change the color of only one tab in navigation menu bar of wordpress. I was using Ubermenu MegaMenu plugin but that didn’t provide any option for this. So i did it myself. You may also face such situation so following is smart solution to do that.

Let’s say you create a menu item “HOME” in your wordpress menu. When you create it in wordpress, a specific ID and Class is assigned to that menu item like:

&lt;li id=&quot;menu-item-1704&quot; class=&quot;menu-item menu-item-type-post_type menu-item-1704&quot;&gt;&lt;a href=&quot;http://www.wordpress.org&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;

WordPress always assigns each “menu-item”  a unique ID Number.  So open stylesheet of your theme that styles menu, usually style.css or otherwise open header.php  file of your theme and add following code between head :


#menu-item-1704
{
    background:red;
}

For sake of example, i have used minimum css but you can add other menu properties as well for #menu-item-1704 to extend it’s style.

Another problem you may face is to find ID of your menu item. To find out id of your menu item that you want to style differently, go to Appearance > Menus.  Hover your mouse on menu item tab:

menu-navigation-inst-01

See the URL that will appear in browser status bar, it will look like:

www.somewebsite.com/wp-admin/nav-menus.php?edit-menu-item=377#menu-item-settings-377

menu-navigation-inst-1

 

Here 377 is menu item ID.

So once you find the menu item ID, you can easily style that specific menu item as i mentioned above.

Please share this post with others –Sharing is Caring !!!