mirror content from page within multisite

i would like to completely mirror content from a page within my multisite network. i am using the switch to blog function to find the correct site/page and then calling the content of that individual page specifically. it all works perfectly except only for logged in administrators.

i would really love to have this functionality work across the board (for public and authenticated users) not just for logged in admins.

here is my code that is working albeit only for administrators:

        global $blog_id;
        $current_blog_id = $blog_id;

        //switch to the main blog which will have an id of 2

		<?php query_posts('page_id=2');
                if (have_posts()) : ?>
                <?php while (have_posts()) : the_post(); ?>
                <?php echo the_content('Continue reading »'); endwhile; ?>
                <?php endif; ?>
	<?php restore_current_blog(); ?>

thank you in advance for your help!

  • Kimberly
    • Champion of Loops

    Hi Andrew!

    Welcome to the WPMUDEV Community!

    Looking at the codex for your function I see that you may not be able to use this for the front end.

    ref: http://codex.wordpress.org/WPMU_Functions/switch_to_blog

    This switch is to be used for internal and admin area functions. It's too expensive a query to run on the front end.

    That's from the codex page :slight_frown:

    Let me know if I've misunderstood!



    If the above action did not result in the resolution or common end to this ticket then please feel free to come back here for comment. Just be sure you mark "Not Resolved" to re-open or we might miss it! :slight_smile: Thanks!

  • invest2s
    • Flash Drive

    hi kimberly-


    oddly enough, i use that exact same switch to display a global navigation bar across all of my sites/blogs.

    it does work in that case

    <?php //store the current blog_id being viewed
    global $blog_id;
    $current_blog_id = $blog_id;
    //switch to the main blog which will have an id of 1
                <div id="logo">
                    <a href="<?php bloginfo('siteurl') ?>" title="<?php bloginfo('name') ?>"><?php bloginfo('name') ?></a>
                <!-- END LOGO -->
                <!-- START NAV -->
                    $color_menu = 'black';
                    if(get_option('bl_color_dropdown') AND get_option('bl_color_dropdown') != '') $color_menu = get_option('bl_color_dropdown');
                    $options = array(
                        'theme_location' => 'nav',
                        'container' => 'div',
                        'container_id' => 'nav',
                        'menu_class' => 'level-1 ' . $color_menu,
                        'depth' => '3',
                        'fallback_cb' => null,
                        'walker' => new description_walker()
                <!-- END NAV -->
                <?php restore_current_blog(); ?>

    it works great to display a global navigation.

    any reason you can think of why it would work and not the other example i posted initially?

    are there any other solutions to mirroring content from one network blog to another?


  • invest2s
    • Flash Drive


    thanks, yes i found that plugin before.

    the odd thing is that when i use it or a switch to blog function only a portion of my page shows.

    it's more than likely my custom function that i'm calling with a shortcode on that page.

    thank you again. if i have any useful updates to this thread, i will post them.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.