Could someone please explain why this code always returns name of the first blog (with id=1)?
$blog_ids = array(1,8);
foreach ($blog_ids as $blog_id) {
switch_to_blog($blog_id);
$blogname = get_bloginfo('name');
echo "blog: ".$blogname."<br />";
restore_current_blog();
}
And this one f.e. works fine:
switch_to_blog(1);
$blogname = get_bloginfo('name');
echo "blog: ".$blogname."<br />";
switch_to_blog(8);
$blogname = get_bloginfo('name');
echo "blog: ".$blogname."<br />";
And more importantly, could someone help me with fixing the first part? In the end I want to use wp_insert_post in order to post to multiple blogs. For now, all the posts go to blog with id=1.
Thanks.