How to Get a List of Sub Blogs without Using get_blog_list()?

The get_blog_list() function has been deprecated from v3.0. How does one get a list of blogs in a multisite blog?

Related posts

Leave a Reply

4 comments

  1. You could directly query your database.

    global $wpdb;
    
    $blogs = $wpdb->get_results( "SELECT * FROM $wpdb->blogs ORDER BY blog_id" );
    

    This will return an array containing all your sites on the network, you can then use a foreach statement to build & populate your own array.

    Also remember to carefully read the codex page on interfacing with the WP database when using $wpdb particularly pay attention to the $wpdb->prepare method when doing more advanced queries.

  2. There are plugins for this like http://wordpress.org/extend/plugins/multisite-recent-posts-widget/.

    I’ve used a similar plugin (derivative of the plugin above) code (original source no longer available, hence no link, only found it two weeks ago as well!) to create a Multisite sitemap Page template that lists the most recent 300 new multisites.

    You can download my Page template at http://www.google-adsense-templates.co.uk/seo-plugin/sitemap-multisite.zip will only work with the Talian 05 SEO theme, but you could easily copy the relevant code to your own themes Page template.

    David