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

is there a good and efficient way to fetch all WPMS blogs with archived set to true? Because there doesn't seem to be a function to get all blogs I have added the admin user to all blogs. Then I do a get_blogs_of_user(1, false). This fetch all blogs that are active, but I'm looking for an efficient way to fetch all blogs that is archived.

I guess I can do something complicated e.g. call get_blogs_of_user(1, true) then get_blogs_of_user(1, false), then find the difference and check if they have the archived bit set one by one, but is there some better way to do this?


share|improve this question
up vote 1 down vote accepted

You can go directly to the database via $wpdb.

$wpdb->get_results( "SELECT * FROM $wpdb->blogs WHERE archived = 1" );

Or wrapped up in a function:

function wpse34731_get_archived_blogs()
    global $wpdb;
    if( empty( $wpdb ) ) return;

    $blogs = $wpdb->get_results( "SELECT * FROM $wpdb->blogs WHERE archived = 1" );
    return $blogs;
share|improve this answer
Thanks, of course. blush – grm Nov 26 '11 at 16:08
Sadly it doesn't return the name of the blog. You wouldn't know if it's easy to get that as well or do I need to go into each seperate options table? If so, this is not very efficent afterall. – grm Nov 28 '11 at 15:41
It's stored in a separate table. Try using get_blog_details to fetch the info. – chrisguitarguy Nov 28 '11 at 16:11

Your Answer


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.