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:

32 thoughts to “WordPress MU List Blogs”

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


    1. Guy-Michel,

      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. Motto,

    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.


  3. 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?

  4. Matt,

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


  5. 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 .'';

  6. 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

  7. 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!

  8. 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.

  9. 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?

  10. 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.

  11. 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…

  12. Chefpogo,

    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

  13. 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).


  14. 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.

  15. 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 '';

      1. Hohoh!!! thank you very much =)

        That way, I will continue my project WPMU.

        I wish you a great day here in Brazil!!!

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

Comments are closed.