I’ve been working on a WordPress Multisite installation that is going to eventually have upwards of 20,000 sites. Somewhere around the 50 site mark, I noticed the WordPress admin panel was beginning to slow down. And, after some investigation, I discovered the “My Sites” menu in the admin bar was part of the problem.
Using the admin_bar_menu action hook, we can bind to this admin bar (like most things in WordPress), and remove items we don’t want to show.
add_action('admin_bar_menu', 'remove_admin_toolbar_items', 999); function remove_admin_toolbar_items( $bar ) { $bar->remove_node( 'wp-logo' ); $bar->remove_node( 'my-sites' ); $bar->remove_node( 'comments' ); $bar->remove_node( 'new-content' ); $bar->remove_node( 'wp-mail-smtp-menu' ); }
In my case, I am removing the logo, my sites, comments, new content and a menu added by an SMTP plugin for mail. Just by removing the My Sites menu from the admin bar, my load times went from sub-10s to a couple of seconds. I more than halved the load time of the WordPress admin panel.
Now, to determine the names of the items in your admin bar (if you want to remove other things) you can inspect the page by hitting F12 and bringing up your developer tools.
All you have to do is remove wp-admin-bar-
from the ID to get the node slug we then pass to remove_node
. If you end up removing a heap of things from the admin bar, it might even be worth just removing it entirely.
Hi there,
This worked like a charm for me and thank you for that, however I only wanted to hide for everyone except for me as a super admin. Is there a way?