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?


1 Answer 1


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;
  • 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
    Commented Nov 28, 2011 at 15:41
  • It's stored in a separate table. Try using get_blog_details to fetch the info. Commented Nov 28, 2011 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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