• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

How to Remove the My Sites Menu From the WordPress Admin Bar

Wordpress · October 19, 2021

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.

Dwayne

Leave a Reply Cancel reply

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Thebe
Thebe
6 days ago

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?

0

Primary Sidebar

Popular

  • Testing Event Listeners In Jest (Without Using A Library)
  • How To Get The Hash of A File In Node.js
  • How To Mock uuid In Jest
  • How to Copy Files Using the Copy Webpack Plugin (without copying the entire folder structure)
  • Which Neural DSP Archetype Plugins Should You Buy?
  • Removing A Character From The Start/End of a String In Javascript
  • Smoke Detector Randomly Goes Off Early Hours of The Morning
  • How To Install Eufy Security Cameras Without Drilling or Using Screws
  • How to Use Neural DSP Archetype Plugins With the Quad Cortex
  • NBN Box Installed Inside of Garage, Where Do You Put The Modem?

Recent Comments

  • Thebe on How to Remove the My Sites Menu From the WordPress Admin Bar
  • Maccas worker jn the 2000s on Dear McDonald’s: bring back the Warm Cookie Sundae, you cowards
  • Anamika Singh on Testing Event Listeners In Jest (Without Using A Library)
  • Stefan on A List of WordPress Gutenberg Core Blocks
  • pandammonium on A List of WordPress Gutenberg Core Blocks

Copyright © 2022 · Dwayne Charrington · Log in

wpDiscuz