Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 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
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.