Display posts from one network site on another

Question

I’ve got to be missing something very basic here. I want to display posts from one site on another. No custom queries (yet), just the plain old posts.

if ( get_current_blog_id() == 1 ) :
    // do regular main site stuff;
elseif ( get_current_blog_id() == 6 ) :
    switch_to_blog( 1 );
    // pull in posts from main blog
    if ( have_posts() ) :
        while ( have_posts() ) :
            the_post();
            get_template_part( 'content/post' );
        endwhile;
    endif;
    restore_current_blog();
else :
    // nothing special
endif;

When I try this, I get the post data from the site I’m trying to pull into (site 6) rather than site 1. I can echo get_current_blog_id() while in the loop, and it tells me I’m in site 1, but the post content ends up coming from from site 6.

0
, nickfindley 8 months 0 Answers 93 views 0

Leave an answer