This came up in the WordPress Support Forums. If you use Multisite, the WordPress toolbar (at the top of your site when logged in) has a special item called “My Sites” which shows all the sites of which you are an administrator. This is great and works as a quick jump to get to a different site really fast. It has problems, though, in that if you make a network with a bunch of sites named the same thing, it’s hard to tell which site you’re on.

Now I know what you’re thinking! “Mika!” You say. “Mika, come on, no one has 100 sites with the same name unless they’re doing what you say is a terrible idea, and duplicating sites!!”

Au contraire, mon fr̬re. There are a few totally understandable reasons why this might happen. Fairly recently I was helping a school sort out Multisite, and they wanted a site for each classroom (easy) and the names of the sites would all be the same: Super Cool School РClass Frog

And their ‘My Sites’ list was all the same.

An example of a site list where the names aren't really readable because they're too long

As you can see, WordPress wisely puts a practical limit on the title length, which makes sense. Now when I was faced with this problem, I remembered something that had come up in the forums, where someone wanted the ‘language’ of the site to show up in the site list, so his sites would be showing as “SiteName (en)” and so on. Since he was using the site path (en, de, etc) as the site’s slug, it was easy for him to come up with this, once I (accidentally) pointed him the right way:

Plugin Name: Show Site Path
Description: Show Site Path in My Sites Menu

function helf_customize_my_sites( $wp_admin_bar ) {

    $mysites = $wp_admin_bar->user->{'blogs'};

    foreach($mysites as $site) {
      $site->blogname .= ' (' . $site->path . ')';

add_action('admin_bar_menu', 'helf_customize_my_sites');

I say it was an accident because I did read the question wrong, but it actually gave me the answer to my schools. They too used the classroom name as the site path, so for them I changed one line:

    foreach($mysites as $site) {
      $site->blogname = '$site->path';

That was it. Now the sites showed up the way they wanted.

Reader Interactions


  1. This snippet is achingly cool. I needed this for a project due next month. Thanks!

%d bloggers like this: