• 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
10 months 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

  • Thoughts on the Flipper Zero
  • I Joined Truth Social Using a VPN and Editing Some HTML to Bypass the Phone Verification
  • How To Install Eufy Security Cameras Without Drilling or Using Screws
  • How To Get The Hash of A File In Node.js
  • Wild Natural Deodorant Review
  • The Most Common iPhone Passcodes (and how to guess them)
  • How to Record With the Neural DSP Quad Cortex in Reaper (DI and USB Recording)
  • Neural DSP Reveal Details About the Long-Awaited Quad Cortex Desktop Editor
  • How To Paginate An Array In Javascript
  • NBN Box Installed Inside of Garage, Where Do You Put The Modem?

Recent Comments

  • CJ on Microsoft Modern Wireless Headset Review
  • Dwayne on Microsoft Modern Wireless Headset Review
  • CJ on Microsoft Modern Wireless Headset Review
  • john on Microsoft Modern Wireless Headset Review
  • Dwayne on Why You Should Be Using globalThis Instead of Window In Your Javascript Code

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz