WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way of retrieving a list of all blogs and their URLs in a MU network? Can I find them somewhere in the database?

I'm also confused about the database schema. I have two different networks, one network has lots and lots and lots of tables with names such as wp_{id}_posts whereas the other network - which is admittedly much simpler - only has one of each kind of table. Notably it also has a table wp_blogs which I cannot find on the first network.

Could this be because of the first network was installed way back when the MU feature was new (3.0) and the other network is recent (3.4)?

share|improve this question
up vote 1 down vote accepted

You can use something like this

global $wpdb;
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM 
                             wp_blogs ORDER BY blog_id" ) );

Iterate through $blogs to get what you need.

There is a function get_blog_list(), but it's been deprecated, so you probably shouldn't use it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.