You might be running up against WordPress’s global $blog_id
variable in test case #2.
Try this:
foreach($sites as $my_blog_id => $name) {
switch_to_blog($my_blog_id);
$sites[$my_blog_id] = get_bloginfo('name');
restore_current_blog();
}
Related Posts:
- Search widget breaks when using multiple loops?
- Multisite – Get current post id
- Display post category in foreach loop with category link
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Pagination with an array of post objects?
- List authors with the last post title and order by last post date
- How to avoid duplicates when creating recent network posts
- How can I remove the first two words and shorten get_the_title()
- Limiting the amount of posts retrieved by the loop
- Defining ‘last’ class on foreach blog posts
- Related posts loop based on tags AND categories doesn’t work without at least one tag assigned
- Loop through all product posts?
- How to display different number of posts
- If Specific Post, Link Elsewhere
- Accessing post->ID outside of the loop for listing child pages
- How to filter posts that belong to a specific category only if that is the only category
- WP Query – duplicated posts once including tags in search results
- Most recent post from another database
- wp_tag_cloud() and the_taxonomies() work but not the_tag()
- how to set beforsend option in wordpress ajax methods
- get_next_post() and get_previous_post() return wrong posts
- Show all posts in sidebar in single.php
- Split WordPress Latest Posts in Multiple Columns and Rows with one single loop [closed]
- Avoid duplicate post from same Taxonomy
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Display post from current category and same tag?
- Alternate row and columns every X posts
- page.php showing loop of posts and not page content
- Inserting custom data to the_post() during loop
- Adding specific post category between posts in loop
- How To Get Posts With A Specific Word
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- How do I restart my loop with get_next_post()?
- WordPress Custom Fields (Checkboxes with multiple values)
- How to display posts on a static page? (like search loop)
- Child_of not displaying all children posts.. via get_posts
- Multiple loops are not reset
- I would like to have different styles for my posts based on the content of each post
- Most liked page not displaying posts
- Displaying Latest Posts on a Page
- Display all posts that were published before full post on single.php
- How to make number of blog posts a custom field?
- How to show last post of each website of a MU wordpress in HomePage
- Exclude category from
- WordPress Loop – Next 3 Posts
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- problems with loading posts in a table-row
- Blog page pagination is not working after using the offset argument
- Posts will not display on page-mypage.php
- WP Query – Posts Per Page not working in combination with category__in
- How can I add extra word in permalink when someone click download button?
- How to display content from the main blog on another from multisite network as it would be its own
- More then one menu items are assigned with “current-menu-item” class
- Multisite: Can’t Post or Create Categories
- Pausing and Resuming WP_Query results
- Pulling in post category and children within category
- Unable to restore from backup – how to obtain old blog posts?
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Post Loop Missing Most Recent Post
- remove post that has no content
- Trying to use AngularJS with WordPress without any API
- How to : pagination in 3 different custom loops on the same page
- Sharing post from archive page (loop) doesn’t work
- Get Image tag from content of post
- Start WP Pagination From Number 1 in URL
- WordPress Multisite – Create Default Post and New Category On New Site Install
- Creating a post from data returned from HTML form
- Set static page/post from another blog on same network
- How to add tags (custom taxonomy) to post class css?
- Listing Specific Categories from Current Post with Depth
- How to exclude visited posts from loop
- Use two different post_per_page limits with infinite scroll
- wp_query random post
- How to make the first post in the loop be styled like a “new / featured” post?
- “Right Way” to make custom Loop respect reading settings inside admin panel?
- How to setup a query to output posts by groups of five?
- Redirect to another page using contact form 7? [closed]
- Only display sticky post or latest post in custom loop
- Display post category in foreach loop
- How to order posts in an arbitrary order?
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- How many posts does the loop return?
- Display Posts on Custom Page
- How to make a sum of all posts displayed in a loop
- Possible to alternate between two loops
- Exclude current custom post on single post
- Wrong post title displayed from loop
- Get Value of Post before
- why does wordpress ignore the post args?
- Multiple Loops Breaking Pages
- add to end of post in the loop with plugin
- Page template is accessing the incorrect posts?
- How to WP_Query() from multiple blogs and order them?
- First x post with another template then the others
- Loop doesn’t show title of second post and posts thereafter
- Change all author links in Blog roll
- Count posts on multisite with blog id