The problem is here:
switch_to_blog($subsite_id);
$blog_posts = get_posts();
restore_current_blog();
foreach( $blog_posts as $post ) {
setup_postdata( $post );
get_template_part( 'theme-partials/post-templates/loop-content/masonry' );
}
Your code fetches a number of posts, but then you switch back to the original blog! So now post number 5 means something completely different than it did before.
You need to stay in that other blogs context for as long as you’re working with that blogs data, or all the references will be incorrect. Once you restore
the original blog you can’t use that data.
Additionally, switching to another blog just changes the data that comes back, it won’t load in plugins and code. This means only the filters, taxonomies, post types of the original blog are loaded.
Related Posts:
- WordPress Multisite – global categories
- Get posts from sites in Multisite?
- exclude category from get_posts?
- Multisite – Protect categories from deletion?
- Category page doesn’t use category.php, instead it redirects to homepage
- 5 blogs on one WordPress site
- Multisite blog converting categories to subdomains
- Get id of category from drop down menu
- Adding categories to all blogs at once
- WordPress MU 2.9.2 to 3.0.5 changes to category.php
- How to make category RSS feeds show full content
- Multi-site or categories?
- Show post only if match all categories
- Multisite – create a category in specific site
- WordPress Multisite – global categories
- Default category link for a custom category is a broken link
- Show recent posts from one category on a non-WP site
- Archives for each category on WP Multisite
- get_posts and multiple categories
- Trying to only display 1 category using get_posts
- Get link which associated with a specific category and tag
- How do I share categories across selected sites in a Multisite setup
- get_categories() returns “Uncategorised”
- Get posts from 2 different categories
- wordpress multisite… collect all posts on main blog – exclude category?
- Get posts from specific taxonomy term
- Can Categories be used to hack a Multisite-like setup w/ a single MySql db?
- List all posts in a category with query_post() function
- Hooking to walker_nav_menu_start_el to insert list of subpages
- get_posts ignoring ‘category’ and displaying all posts
- How to pull a list of posts in a category while exluding posts in subcategories of the category
- How to Link to Most Recent Custom Post of Same Term
- get_posts() from parent category only using a shortcode
- How to Sync Menu, Widgets and other masters from Main Website to its Sub Site
- Exclude parent category when getting category posts by slug
- Exclude categories from homepage not longer working
- Showing posts from 2 categories only on category.php
- get all categories’ latest post in one query
- Categories show 404 error on multisite installation
- Load the last post of a category
- Global navigation in multisite: problem with categories
- Duplicate new categories across multisite network
- Get posts base on category ratio of more then two categories
- Media Library Category Exclude Tree
- global categories – Share specific categories in wordpress multisite
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Using template file for single post in sub-directory multisite
- A search box for all sites – Multisite
- How to create default categories in new installs?
- Multiple parent categories
- How to populate a WordPress install with a lot of categories, quickly?
- How to structure Multisite sites into categories?
- not empty categories don’t show in menu [closed]
- how to call the category of the post
- How to create a custom loop ordered by Categories on a Page Template?
- How to change category id on get_posts array
- get posts from 2 categories. (2 posts)
- how to ask if in two categorys inside if
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Is There a Difference Between Taxonomies and Categories?
- Get Posts Under Custom Taxonomy
- List all subcategories from category
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Category ID inside Category template
- Only one category per post
- Get the children of the parent category
- WP REST API: filter by category 1 AND category 2
- How To Get Parent Category Slug of Current Post
- Display All Products by Category with WooCommerce
- What is the difference between a “tag” and a “category”?
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- How to check if I’m on the last page of posts?
- Display posts from the same category using next/previous post link
- How would I get a taxonomy/category list inside a Gutenberg block?
- Can I set a default featured image for a category?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- Force category choice before creating new post?
- Gutenberg editor add a custom category as wrapper for custom blocks
- How to show related posts by category
- WooCommerce: List All Categories
- How to get category and archive title?
- Get category ID from category slug (not working)
- How do I remove “Uncategorized” from posts with more than 1 category?
- Get rid of WordPress category, tag and author archives?
- Individual rss feed entry length for categories?
- How can I create a category landing page followed by pages of posts?
- Remove parent category from permalink? Basically only have the child category?
- Custom permalink structure leads to be 404 on pagination
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Posts URL structure like site.com/category/the-post-title
- Can’t custom taxonomies have same terms (slugs) as categories?
- How to get permalinks with category base working with sub-categories
- How to remove the term “category” from category pagination?
- Using wp_category_checklist in a widget
- WP 3.9 TinyMCE no longer loads on category description editor
- On the category page, get the category object
- Get only the top level categories using get_categories() without foreach loop
- Get all categories and posts in those categories