Trouble passing IDs of multisite blogs to foreach loop – help please?
-
I’m building a directory and am stuck on getting the foreach to loop through the multisite’s blog IDs. As you can see from the comments, the wpdb is working fine, the print_r’s show that the array is filled, but when it gets to the foreach, it doesn’t work. The print_r on site_blog_id in the foreach loop shows they’re empty. Setting it manually in the loop makes it work fine, so it’s definitely the foreach. I’m highly puzzled because this seems identical to many examples of array-foreach code I’ve seen here, including the ones on the wpdb docs page.
Any help will be greatly appreciated!
Davidglobal $wpdb; $site_blog_ids = $wpdb->get_results($wpdb->prepare("SELECT blog_id FROM wp_blogs where blog_id > 1")); // get all subsite blog ids print_r( $site_blog_ids ); // checkem - output is "Array ( [0] => stdClass Object ( [blog_id] => 2 ) [1] => stdClass Object ( [blog_id] => 3 ) [2] => stdClass Object ( [blog_id] => 5 ) ) " foreach( $site_blog_ids AS $site_blog_id ) { //iterate through the ids print_r( "siteid= ".$site_blog_id."</br>" ); // checkem - this shows no blog ids output at all ??
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Trouble passing IDs of multisite blogs to foreach loop – help please?’ is closed to new replies.