I'm using switch_to_blog to get all the posts from the blog_id. Is it possible to get all posts from other sites? Also I've tried to use foreach as mention on the codex documentation.
This is what I've tried...
global $wpdb, $paged, $blog_id;
$site_blog_ids = $wpdb->get_results($wpdb->prepare("SELECT blog_id FROM ".$wpdb->prefix."blogs where blog_id > 1")); // get all subsite blog ids
foreach($site_blog_ids as $bids){
echo '<pre>';
print_r($bids->blog_id);
echo '</pre>';
switch_to_blog($bids->blog_id);
restore_current_blog();
}
$video_args = array (
'post_type' => 'video',
'post_status' => 'publish',
'posts_per_page' => -1,
'paged' => $paged,
);
$video_query = new WP_Query( $video_args );
but still no luck..