How can I remove the WP menu from the admin bar?

I never use the WP menu (the logo and its child items) except when I click it accidentally. And it is wasting my time when I navigate per keyboard. Plus, the support page is not our site.

How can I remove it?

3 Answers
3

This menu is added in WP_Admin_Bar::add_menus() with an action:

add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );

To remove it take the same action – just one step later. The following code works as a mu plugin or as a regular plugin:

<?php # -*- coding: utf-8 -*-
/**
 * Plugin Name: Remove WP Menu From Tool Bar
 */
if ( ! function_exists( 't5_remove_wp_menu' ) )
{
    // The action is added with a priority of 10, we take one step later.
    add_action( 'init', 't5_remove_wp_menu', 11 );

    /**
     * Remove the WP menu action.
     */
    function t5_remove_wp_menu()
    {
        is_admin_bar_showing() &&
            remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
    }
}

It has a GitHub address too.

After the installation the sites menu is the first one.

See also this great answer for other menus and more details about the inner workings of the admin bar/tool bar.

Update

The old code doesn’t work anymore, this one does:

add_action( 'add_admin_bar_menus', function() {
    remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu' );
});

Leave a Comment