You are looping through the posts queried before your switch_to_blog() statement. Your code appears to be from a page template which is executed AFTER the main query has run.
To be clear, the main query is run before the template code is executed. Switching to another site after that does not update the query, therefore your loop is iterating through the original blog (#6).
Try something like this instead:
switch_to_blog( 1 );
// pull in posts from main blog
$query = new WP_Query();
if ( $query->have_posts() ) {
while ( $query->have_posts() ) :
$query->the_post();
get_template_part( 'content/post' );
endwhile;
wp_reset_postdata();
} else {
// none were found
}
restore_current_blog();
EDIT: updated to use OP’s original loop and template part.
EDIT 2: clarified order of execution in the first few sentences.
Related Posts:
- How can I trust switch_to_blog()?
- Sharing Dynamic Sidebars across Multisite Blogs
- latest 5 posts using switch_to_blog loop
- Switch_to_blog() outside wordpress
- why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?
- Upload images from one site to another in Multisite
- What is the way to share data between sites in a multisite
- get post id by $content (so by post content)
- Register submenu on network menu from the subsite
- Include Site 1 Posts in Query for Sub Sites
- Sort posts according to date
- Multisite switch to blog
- Best Practise: Linking to WPMU sites from other sites
- Trouble with SQL SELECT inside switch_to_blog()
- Get variable from previous blog while using switch_to_blog
- switch_to_blog($blog_id); still writing to main blog
- fatal Error undefined function switch_to_blog()
- How to get all pages on specific blog after switch_to_blog?
- Do “switch_to_blog()” and “restore_current_blog()” re-run the filters?
- Access from template info of another blog (in the same network)
- Get the excerpt by page ID from another blog in a wordpress multisite?
- Memory growth with new additions to WordPress Multisite
- Can i merge 2 new WP_Query($variable) ‘s?
- How to reliably flush rewrite rules on multisite?
- Convert a Multisite WordPress install into a Single site
- Why are my roles not visible in a Multi-site/Network?
- Using wp_insert_post() with Networking enabled
- Multisite: How to store global options vs. site options?
- Hide a theme on list of themes in wp-admin without editing core files
- How can I manage all multisite pending comments in one place?
- WordPress Multisite Network installation and dev questions
- How properly delete only one site (blog) from the Network in WordPress Multisite (WPMU)
- List all sites in multisite
- Turn off trackback/pingbacks and comments on all existing multisite sites
- My subsites accidentally went from one multisite network to another. How do I change it back?
- How to change a WordPress network domain
- Multisite sub-site dashboard redirects to /wp-admin/
- Trying to access second site dashboard on a multisite configuration proceeds to an error
- How to configure WordPress Multisite by bash script?
- Creating Admin Options Page where users can make changes to a theme
- Creating multisite in wordpress using php
- How to use both British and American English?
- Members area with externally-managed htaccess / htpasswd authentication?
- Using Multisite with a CDN?
- WordPress Multisite Sites show in Dropdown but not in Sites menu
- WP Multisite Static Frontpage
- Depth > 2 possible with multisite?
- What are Attributes used for in a WordPress Multisite?
- Architectural reasons behind sitemeta, blogs, home, site and DOMAIN_CURRENT_SITE redundancy
- Redirecting non www to www ONLY for domain, subdomain without www
- WordPress multisite with subdomain and directory simultaneously
- WordPress Multisite Question
- Wrong Redirect/Rewrite Rules?
- Four columns in the wp_users table
- Is this the right set of records for Route53 domain to point to a mapped domain in a multisite? [closed]
- Initiate multisite with blog_id outside of wordpress
- Show media-frame-menu on custom Media Frame
- How to run a WordPress site across multiple ccTLDs?
- Why is MySQL receiving such a large serialized object?
- How can I remove the folder from a Multisite URL?
- How to get blog_id of an MU site when running a custom function on the parent site
- WordPress multisite domain
- WordPress multisite not work wp-admin
- How to install seperate theme on certain page
- Using Same User Database on Subdomain
- Multisite subdomain-site redirects to primary site
- Permission warning in wordpress multisite
- Static directories in a WordPress multisite network
- Trying to Decide Between Reverse-proxy and Multisite
- Export / import
- Remember language choice on multisite website
- How to post same content on multisite?
- Configure redirects with web.config
- Will resetting my database affect other sites on my multisite WordPress install?
- Events Calendar Multisite 404 for events
- WordPress Database Cleanup
- Multisite – How sync posts to multi sites
- WordPress multi site network setup on local server shows sub-directories error
- Optimal setup for Multi Domain WordPress with Woocommerce
- Sub-directory domain on subdomain multisite?
- Blog switch wpml string translation (multi-site)
- Multisite custom rewrite urls
- Manually insert post into MULTISITE database: Need to specify the TABLE
- Transfer Part of Multisite to new Domain
- Subdirectory and domain multisite installation
- How can I write a rewrite rule to appear to move a multisite?
- Is there any way to give all users access to one blog in a multisite network without using a plugin?
- Some widgets on Multisite not showing up in template for particular theme
- MP4 upload ok, but HTTP500 if I update the file (multisite)
- In a loop, do not display content that does not have a thumbnail
- Global site feed plugin/function for custom post type?
- Run WordPress multisite from secondary volume on AWS EC2
- How to set an option for all sites in my Multisite network?
- Does the ‘init’ hook works for all sites in multisite?
- I’m getting a 404 NOT_FOUND CODE: ‘DEPLOYMENT NOT FOUND on wordpress multisite installation on my sub domain
- Non-super-admin users cannot access CPT even though I have explicitly added the capabilities to the user role
- Multisite Network Admin
- wordpress multisite set up on localhost, redirects to live site
- Staging site on subdomain – all links dont work except home page
- Multisite: merging two subsites in the main site