all. Just trying out switch_to_blog() as a way to have a child site get some news items from the parent site. Problem is, the parent site--first tables in database--doesn't have a number, i.e., tables are like www_posts--there's no number to put in the parentheses, 0 doesn't work, empty doesn't work.

How can I reference this original install? Also, is it no longer cool to use switch_to_blog()?



switch_to_blog(1); to switch to the root (primary) blog and pull post info.

restore_current_blog(); to switch back.


Another option would be to use site transients store the news items. That way it would be accessible from all network sites and you wouldn't have to call switch_to_blog to access them as I believe it is quite server intensive.

Transients API

And the specific function you would want to use for network access would be:

set_site_transient('recentnews', 'yournewsoutputhere', expiretime);

<?php echo get_site_transient('recentnews'); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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