Return a list of sites on the network

Here’s a simple internal function that will return a list of all sites in the network. The code below just shows them all and unlinked.

$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
echo 'Blog '.$blog['blog_id'].': '.$blog['domain'].$blog['path'].'

Paste that somewhere in a theme file or page template and there you go. Hope someone finds it handy and gets inspired to write a snazzy plugin, possibly a shortcode.

About andrea

City kid turned country wife, obsessive crafter.


  1. Someone should extend it and use the transients API to store this and automatically update it when a new site is created otherwise it wouldn’t scale.

    • Yep, I wouldn’t use this on a large site.

      A small one, less that a hundred sites, yes. There will be a lot of those now. :D

      So…. get on that, will ya? ;P

  2. Would be nice if that was easily extended to be able to sort the list other than by ID or latest updated.

  3. Is there a plugin for this? It would be really helpful..: )

  4. Just as a quick experiment I just put the get_blog_list() function into a (very) simple Plugin as a shortcode and it works OK. However, this function is now deprecated so is not an option to use now.

    This is not a big problem though as there are a lot of other useful internal multisite related functions to consume, and I plan to write some of my own as wrappers around custom queries.

    In-fact I have been discussing with Lorelle about a large scale Plugin that would be an efficient way to aggregate network blog info onto the front portal page.

    I am a bit limited at the moment as I am just dipping my toe into the network feature of WordPress and so my lack of experience/knowledge is hindering me somewhat but soon I hope to be able to put together something more useful!

    Any specific requests to add to the list?

    • If you’re trying to aggregate all the posts to the front… why not use sitewide tags plugin?

      • Don’t ask me, I’m new to this multisite thing! :)

        It is a great new feature, wish I had taken a look a while ago. I will look into the Plugin you suggested. Thanks.

  5. Ahh, OK just been reading over an e-mail from Lorelle. The reason she suggested a new Plugin approach was the fact that to use the sitewide tags Plugin you have to live with having to create a ‘hidden’ blog.

    This then pulls in all the content to it, and then you have to do queries and such to pull from that to the portal/gateway blog. I believe this approach is not considered that efficient etc. and so a more direct way is desired.

    Not sure how accurate I am on the above, my multisite terminology is not upto scratch yet. Still very much finding my feet.

    What is your opinion of the sitewide tags Plugin? Do you love it, put up with it, secretly wish for something better etc? :)

    Not having the user experience of WordPress multisite it is hard for me to evaluate from an initial impression.

    • The SWT plugin has a checkbox to use the main site/blog as the tags blog. If you use a separate tags blog, it’s only hidden from search engines to prevent issues with duplicate content. Otherwise it’s publicly accessible.

  6. Hello,

    Thanks for the great code snippet, Andrea!

    I have the following code listing all of my 3.0 network sites via a page template, with each blog’s title hyper-linked to the site (then a line break after each one).

    The problem I’m having is that it’s grabbing the title of my main blog for all sites instead of each individual sites title.

    <?php $blog_list = get_blog_list( 0, 'all' );
    foreach ($blog_list AS $blog) {
    echo "” . $blog_title . “” . ”;

    I can’t seem to figure out how to grab network site titles instead of my main site.

    Thanks for any help.