WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 40+ sites showing up in the "My Sites" page with more planned. Unfortunately WordPress doesn't sort them alphabetically, and that makes it a pain to move from site to site during routine updates and maintenance. I've tried adding

asort($blogs);

to wp-admin/my-sites.php, but that doesn't help either. And regardless, I'd rather do this using a filter in functions.php rather than modifying a core file. Making the issue even more complex is the fact that the list is split into four columns, and while a horizontal alphabetical ordering would be a huge improvement, vertical (by column) would be much, much better.

I've been searching for answers for this for a while and coming up empty, so any help would be appreciated. (My PHP is pretty basic, so spelling out the answer would definitely be appreciated.)

share|improve this question
    
It is not recommended to change core WordPress files other than wp-config.php. – Pontus Abrahamsson Jul 31 '12 at 15:10
    
@PontusAbrahamsson, that’s what he said in the second paragraph. – Synetech Apr 5 '13 at 18:33
up vote 8 down vote accepted

Easy one.

<?php
/*
Plugin Name: Sort My-Sites
Description: Sorts the My Sites listing on both the page and in the 3.3 admin bar dropdown
Author: Otto
*/

add_filter('get_blogs_of_user','sort_my_sites');
function sort_my_sites($blogs) {
        $f = create_function('$a,$b','return strcasecmp($a->blogname,$b->blogname);');
        uasort($blogs, $f);
        return $blogs;
}
share|improve this answer
    
Wow, that's EXACTLY the type of solution I was hoping for: clean and beautiful, and doesn't modify core files. Works perfectly. Definitely not something I could have come up with though. Thanks so much Otto! – Sam Nov 30 '11 at 18:06

This plugin does the job too:

Reorder My Sites

For WordPress Multisite. Reorders the My Sites dropdown menu in the Admin Bar alphabetically. It keeps the main blog at the top.

share|improve this answer

protected by Community Jul 31 '12 at 15:02

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.