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.

[Post to Twitter] Tweet This Post 



Random Posts

    bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
    tabs-top  banner ad
    

    6 Responses to “Return a list of sites on the network”

    1. Pete Mall says:

      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.

      • andrea
        Twitter: andrea_r
        says:

        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. Michael Bishop
      Twitter: miklb
      says:

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

    3. Jordan
      Twitter: documentarymix
      says:

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

    Leave a Reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture.
    Anti-Spam Image