WordPress MU List Blogs

I recently had to make a list of all the active blogs for the university’s blog site running WordPress MU. Here’s the code to do so:

Blog Directory

You’ll notice the query is set to filter out blogs that are marked as archived, spam, private. Also, it hides the main blog from the list.

UPDATE: As posted in the comments by Brad, you can sort these in alphabetical order by the site name by using the following code:

You may also like...

32 Responses

  1. Guy-Michel says:

    Great solution! Thanks for sharing your knowledge. Where do you insert this code
    – which .php file?
    – which line?
    Sorry not really php litterate


    • Eric Juden says:


      It depends on where you are wanting this to show. When I used it, we placed it on the index page of the site, so it was in index.php in our theme files.

      I hope that helps!


  2. mottto says:

    what is?

    echo '<a>siteurl .'">' . $blog_details->blogname .'';

  3. Eric Juden says:


    The code is making a list of links. siteurl is a link to each individual blog. $blog_details->blogname is pulling the blog title from the general settings page.


  4. Matt says:

    This did not work for me. I think you have a typo in your code but I am no PHP programmer. Does this rely on any plugins?

  5. Eric Juden says:


    Can you be a little more specific on what "did not work"? Have you tried enabling WP_DEBUG to see what errors you received?


  6. Guess there have been some typo in one of the lines:
    the line

    echo '<a>siteurl .'">' . $blog_details->blogname .'';

    need to become

    echo '<a>siteurl .'">' . $blog_details->blogname .'';

  7. hmm, the engine is filtering the characters, will try to write it better:

    replace line
    echo '<a>siteurl .'">' . $blog_details->blogname .'';

    with line

    echo '<a href="'.$blog_details->siteurl .'">' . $blog_details->blogname .'';

    hope this time will be displayed correctly

  8. Eric Juden says:


    Thanks, I must have lost part of it while editing my post. I've edited the post and it shows correctly now.



  9. james mino says:

    You can not believe how long ive been looking for something like this. Through 9 pages of Yahoo results and couldnt find anything. One search on Bing. There this is…. Really have to start using it more often!

  10. jondoc says:

    First of all thanks so much for making this available, it saved me some time for sure. I found that the php wouldn't run until I took the curly brace out of the opening line of code and moved it down e.g. {global…

    BTW it works fine in wp3.0 with mu turned on.

  11. Kenada says:

    Could this be done with posts and custom fields?
    I have a review wordpessMU farm set up and we want the main page of the farm to show the latest post from each site with the custom fields. What do you think?

  12. Thank you very much for this – been looking everywhere for an MU blog lister. Worked straight out of the box for MU 2.9.2.

    I'm surprised there isn't a standard plugin for blog listing. Would seem to be saomething most MUs would require.

  13. chefpogo says:

    Hi – thanks – this is excellent – worked immediately on my site.

    However – what other parameters are in blog_details? Is it possible to get blogowner, for example? I'd rather have a list of blog owners than the name of the blgo…

  14. Eric Juden says:


    Here is a list of the fields from blog_details:

    blog_id, site_id, domain, path, registered, last_updated, public, archived, mature, spam, deleted, lang_id, blogname, siteurl, post_count

  15. bedava blog says:

    Thank you for this code. I am use my wpmu blog

  16. Lucian says:

    Thanks, Eric, a nice solution!

    I use your code in a sidebar widget in my WP MU. (I have Exec-PHP plugin installed for the php code to be executed in posts, pages or widgets).


  17. Melinda says:

    This is fabulous! I have one small favor to ask. I am running MU 3.01. Can someone help me with the code to order the list by blog name? I'm not familiar enough with WP functions to know how to pull that off in the code.

  18. David Bell says:

    Thank you so much for this code, it's working really well for my site! Much appreciated.

  19. Brad says:

    Melinda, I wanted the same thing, so we updated the code to show the blog list in alphabetical order by each blog's title. Below is the code.. one caveat: if you have two blogs with the exact same name, this will break.

    base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' AND blog_id != '1' ORDER BY path";

    $blogs = $wpdb->get_results($query);
    $blogList = array();
    foreach($blogs as $blog){
    $blog_details = get_blog_details($blog->blog_id);
    $blogList[$blog_details->blogname] = $blog_details->siteurl;

    echo '';
    foreach($blogList as $blogName => $blogUrl)
    echo '<a href="'. $blogUrl .'" rel="nofollow">' . $blogName .'';
    echo '';

  20. Eric Juden says:

    Yes, it works in the latest version.

  21. RC says:

    This is awesome. Thanks so much. Got it working with 3.1-alpha. Beats the the listall plugin.

  22. Misty says:

    Do you know how to create latest blog excerpt not just the blog list?


  23. andykamto says:

    Its is a very great tutorial & a very useful information for me,thanks for share

  24. Andhie says:

    Works like a charm here!

    Beautiful code, simple but sure.

    Thanks Eric!

  25. john says:

    obrigado. foi muito útil. ๐Ÿ˜‰

    Translated: Thank you. was very useful. ๐Ÿ˜‰

  26. Fabricio says:


    ORDER BY path ?

    How do I sort in alphabetical order?


  27. Gus says:

    How to show the list of blog in horizontally 3 column with the logo of the blogs site and the url?