Disable Toolbar Links

WordPress comes out-of-the-box with a lot of stuff you don’t need.  Most of it can eventually be helpful.  But it loads tons of stuff in the admin bar (toolbar) that you might never need.  For example, I hide the WP logo on client sites and replace it with my own logo.  If I do that, I don’t the WP logo loading anymore… it would just be an extra call that slows down the site.  This is pretty easy to fix, though.

We can use a filter to do the work for us.  Now, its easy to hide the updates admin bar link, without using a huge plugin with tons of other features we don’t need.  Don’t want your users browsing the support forums?  Now you can hide that link and add one that goes to your website or forum site.  Cool, huh?

To keep a certain functionality, simply comment the line or remove it.  Any filter that isn’t commented here will be deactivated.

Add to functions.php or a plugin.

// disable certain parts of the toolbar
function remove_admin_bar_links() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');          // Remove the WordPress logo
    $wp_admin_bar->remove_menu('about');            // Remove the about WordPress link
    $wp_admin_bar->remove_menu('wporg');            // Remove the WordPress.org link
    $wp_admin_bar->remove_menu('documentation');    // Remove the WordPress 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 menu
    //$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('w3tc');             // If you use w3 total cache remove the performance link
    //$wp_admin_bar->remove_menu('my-account');       // Remove the user details tab
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );


Dave Winter focuses in WordPress UI Design and WordPress Plugin Development (some have labelled him a fanatic) but has hands in many other projects, including photography and music. He's never far from a computer... or an iPad (for testing purposes, of course). If you've been to a WordCamp in Southern California, he probably already knows who you are (or maybe not - he's terrible with names). Dave currently teaches courses at California State University, Long Beach alongside his small business at dauid.us (and his students think he's pretty boss).
© 2008-2020, dauid.us