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
- Print Current Post Index number within Loop
- Confirmation box when submitting post for review
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- How to show list of posts by author and category?
- Override the default number of posts to show for a single loop?
- List latest posts in WP-Admin
- Change slug with custom field
- Restrict access to post if it is currently being edited
- WordPress Number of Posts Not Changing With posts_per_page
- Getting an alphabetic post list with two letters onclick on letter
- Find most recent authors
- Get the author of the latest revision
- Multiple loops in same page, without duplicate content
- loop not displaying posts on custom template page
- How to hook a function only when I need to delete permanently a post?
- $post object is null
- The correct way to call posts with ajax
- Divide Loop Into Days & Categories
- str_replace the_title(); blues
- How to display different number of posts
- Adding specific post category between posts in loop
- Multiple loops are not reset
- Exclude category from
- How to exclude latest x posts from a paginated query?
- Multisite: Can’t Post or Create Categories
- Pausing and Resuming WP_Query results
- How to : pagination in 3 different custom loops on the same page
- Sharing post from archive page (loop) doesn’t work
- WordPress Multisite – Create Default Post and New Category On New Site Install
- Creating a post from data returned from HTML form
- Multiple Loops Breaking Pages
- How to WP_Query() from multiple blogs and order them?
- Change all author links in Blog roll
- Showing categories and subcategories with posts
- Is it possible to filter the main loop to exclude posts from a specific category?
- Can’t get full post title if there a spaces in title
- older blog posts not showing in new theme
- How to only publish posts with image in it
- WordPress Query Posts From Category Post on Static Page
- WordPress query undefined offset in loop
- Find Site ID From WP_Post
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- WP_Query: Show 10 posts in date order, first three random
- How include css class based on post ( in loop ) slug?
- WordPress Loop: How to display recent posts in multiple divs
- Cannot implement byline into posts container in single.php
- Optimizing the blog loop
- How to check if there are posts with the same tag
- How to pick “full/thumbnail” images in the loop?
- Change Author Name to Sitename on Frontend
- Different number of posts per row in grid layout
- WP_Query of Category Not Showing First Post
- How come this loop is not working? [closed]
- displaying the categories post
- Using the loop to set locations for all posts on a single google map
- How To Use Custom Fields With .mp3 Links
- A better code for no post format?
- Help Combine These Two PHP Codes
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Shortcode for Comments and Comment Boxes in Post Loop
- Permalink Short code showing unnecessary link text inside the loop
- Multisite how to display merged posts from two sites and sort by latest date?
- Double loop output
- post->ID displays the same ID number for every post
- Posts are not showing up on next page.
- Post are not showing up
- How to make post button to a random post
- How can I have the posts from one word press blog show on the presentation page of another word press site
- Keep post format class with isotope filter
- Make assigning post to a specific category equivalent to assigning it to all categories
- Show a Category Specific Info Box
- How to get all the terms of a post
- How to inject a post within a loop
- List direct children of page
- Unable to get posts with category on my page
- Loop not allowing infinite scroll after post per page limit
- Customise the appearance of 4 specific post ID’s within the loop?
- wordpress radio button on single post page
- what template-part to call, to have my post in the center of the page?
- Create post from form with image
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- Echo author slug in post edit page
- Adding a content rating system
- posts_per_page – Repeats only first posts ‘post__in’ array
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- View post with specific category id and name which I selected in the backend (drop-down option)
- WordPress Ajax load doesn’t work
- users followin the blog post author
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false