Today we’re going to take a step forward and learn how to remove those sometimes annoying items in our admin bar that Plugins and Themes strive to add.
Using the techniques we’ll see in this guide, we’ll identify the node that’s adding the menu and remove it, using a couple of methods.
To start with, you need to identify the node IDs that are shown in the admin toolbar menus.
(First of all) Locate the IDs of the nodes of the different elements
The first thing is to locate the ID of the node, of the toolbar element you want to remove, so you have to inspect the web code to identify it.
To do this, use the browser inspector by right clicking on the menu item you want to remove.

Once the browser inspector opens you will see the ID displayed.
In this example, the full ID would be this:
id="wp-admin-bar-SG_CachePress_Supercacher_Purge"
Code language: JavaScript (javascript)
The node ID will be the part that follows the common wp-admin-bar in all the menus of the administration bar.
In this example, then, the node ID of this admin bar item we want to remove would be SG_CachePress_Supercacher_Purge
.
Remove menu from admin bar
Already identified, we can add the following code to our customization plugin or MU plugin
/* Remove SG_CachePress_Supercacher_Purge menu from admin bar */
function wphelp_remove_sg_menu ($wp_admin_bar) {
$wp_admin_bar->remove_node('new-content');
}
add_action('admin_menu_bar','wphelp_remove_sg_menu', 999);
Code language: PHP (php)
When you’ve added the code, what it does is hook our custom function into the admin_bar_menu and remove the specified node.
The 999 priority parameter helps to ensure that the remove function is executed after the plugin’s add-node function, as the higher the priority the later the function is executed.
That said, the only part of the code you have to modify is to replace the ID of the example node, SG_CachePress_SuperCacher_Purge
with the ID you want to remove.
After you customize and add the code visit your site and reload the page to check that the toolbar menu you didn’t want is finally gone.
This method works on any toolbar item added using the admin_bar_menu
hook, but … unfortunately, not all plugins and themes use this hook to add their custom menus.
So if this method didn’t work for you it’s not your fault (nor mine), but the method simply doesn’t work for that particular plugin/theme we’ve chosen for the example.
What you have to do is try the following method…
Another way to remove the menu from admin bar
As I mentioned, many plugins use the admin_bar_menu hook to add their custom elements to the admin bar, which is the method used in the code above.
But there are many other plugins, like SG Optimizer, UpdraftPlus and more, that use a different hook, wp_before_admin_bar_render, to add their menus to the admin bar.
So if the previous method didn’t work for you and, despite having the ID well identified, the menu that bothers you is still shown, it’s because of this.
The wp_before_admin_bar_render
action allows developers to modify the $wp_admin_bar object before the admin toolbar is even displayed, and that’s why they use it to add their customizations.
In this case the code would be as follows:
/* Remove SG_CachePress_Supercacher_Purge menu from admin bar */
function wphelp_remove_sg_menu() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('SG_CachePress_Supercacher_Purge');
}
add_action('wp_before_admin_bar_render', 'wphelp_remove_sg_menu', 999);
Code language: PHP (php)
When you have added this other code, it works almost the same as the previous one, with these differences:
- Here we use the global variable
$wp_admin_bar
(instead of passing it) - Use
remove_menu
(instead ofremove_node
) - Hook into
wp_before_admin_bar_render
(instead ofadmin_bar_menu
)
As before, check your site, reload the page, and see if the menu you wanted to remove has disappeared.
This alternative method should work for items on the administration toolbar where the first method doesn’t work.
As before, remember to change the ID of the sample node to the one you want to remove.
With one method or another, the result we want is to go from this…

To this.

I’m sure that with one method or another you will succeed.
Remove default WordPress menus from the admin bar (The “Small menu”)
To end these techniques, you can use the first method to remove any of the standard WordPress items from the admin toolbar.
The code would look like this:
/* Remove elements from wp admin bar */
function wphelp_remove_admin_menus($wp_admin_bar) {
$wp_admin_bar->remove_node('wp-logo'); //Removes WP logo
$wp_admin_bar->remove_node('site-name'); //Removes site name
$wp_admin_bar->remove_node('comments'); //Removes comments
$wp_admin_bar->remove_node('updates'); //Removes updates
$wp_admin_bar->remove_node('customize'); //Removes the customizer
$wp_admin_bar->remove_node('new-content'); //Removes Add new
$wp_admin_bar->remove_node('search'); //Removes the search
$wp_admin_bar->remove_node('my-account'); //Removes user menu
}
add_action('admin_bar_menu', 'wphelp_remove_admin_menus', 999);
Code language: PHP (php)
As you see, you can remove everything, just customize the code by adding or removing the elements you want to see or not.
Read this post in Spanish: Cómo quitar menús de la barra de administración de WordPress