Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What's the fastest way to fetch posts/content across a multisite? I had been using SimplePie RSS feeds, but I'm now investigating switch_to_blog(). As switch_to_blog appears to be quite simple to use, I'd much rather use this implementation, but wanted to make sure that it would remain speedy.

share|improve this question

1 Answer 1

yup it is fast, it would be even better for you to use the WP Transients API to cache your query for a short period.

Basically:

if($saved = get_site_transient('SOME_SORT_OF_ID')){
    echo $saved;
} else {

    ob_start();

    switch_to_blog(x); // x being the blog id your want to switch to
    // Do your quering and echoing here

    restore_current_blog(); // Revert to current blog   

    set_site_transient("SOME_SORT_OF_ID", ob_get_contents(), (60 * 60)); //Save query for one hour

    ob_end_flush(); // Echo and End Buffering      

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.