Remove Menu Items From WordPress Admin Bar

How to Remove Menu Items From WordPress Admin Bar

in WordPress Admin
Google+ LinkedIn

In version 3.1, WordPress added a fixed menu bar at the top of the website, it’s called WordPress Admin Bar. Ever since the introduction of the WordPress admin bar, it has been a topic of discussion among developers. Some developers hate it because in some cases it breaks the website design and for that matter, they want to disable admin bar completely. But there are users, absolutely love it because it provides shortcuts to various admin sections and tasks which saves a lot of their time.

Although WordPress comes with many default menu items but not all links are useful for everyone. For example I hate visit site drop down menu item under sitename menu because of the fact that both of the links point to same address and because of that it was unnecessary and pointless to add a child item to accomplish the same. I also never use child menu items (documentation, support etc) of WordPress.org menu. And I am sure there would be some menu items that you also want to remove from admin bar. Lucky for us, WordPress allows us to customize the admin bar and add or remove menu items as we require.

To remove menu items you just need to add the following function to your functions.php file. Remove or comment out lines for menu items that you want to want to keep.

// remove menu items from wordpress admin bar
function wcs_admin_bar_remove_menu_items() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu( 'wp-logo' );          // Remove the wordpress logo
    $wp_admin_bar->remove_menu( 'about' );            // Remove the about link
    $wp_admin_bar->remove_menu( 'wporg' );            // Remove the wordpress.org link
    $wp_admin_bar->remove_menu( 'documentation' );    // Remove the documentation link
    $wp_admin_bar->remove_menu( 'support-forums' );   // Remove the support forums link
    $wp_admin_bar->remove_menu( 'feedback' );         // Remove the feedback link
    $wp_admin_bar->remove_menu( 'site-name' );        // Remove the site name link
    $wp_admin_bar->remove_menu( 'view-site' );        // Remove the view site link
    $wp_admin_bar->remove_menu( 'updates' );          // Remove the updates link
    $wp_admin_bar->remove_menu( 'comments' );         // Remove the comments link
    $wp_admin_bar->remove_menu( 'new-content' );      // Remove the content link
    $wp_admin_bar->remove_menu( 'my-account' );       // Remove the user details tab
}
add_action( 'wp_before_admin_bar_render', 'wcs_admin_bar_remove_menu_items' );

Share the love

If you like this snippet, share it with others!

One Reply on "Remove Menu Items From WordPress Admin Bar"

  1. Richard

    Nice one.
    I was looking for something like this.

    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *