paul_fury
Member
Posted 14 years ago #
I have 4 blogs now with Word Press Mu. I want to be able to query each blog from the site index page and have different loops after each one to display some entries from each blog (so 4 query calls and 4 loops).
I'm having trouble finding how to do the query part before each loop. This is done automatically when I'm working with a page for a particular blog, but for the site index page I'll have to do it manually 4 times.
I think I'm supposed to use wp_query() somehow, but I'm not sure. Does anyone know how to load the entry data from a particular blog before the loops?
Thanks
check the functions switch_to_blog and restore_current_blog
If you just want info from specific blogs, this works great.
Overall though, if you want to pull all entries from all blogs on the system, there are much easier ways. :)
paul_fury
Member
Posted 14 years ago #
I tried the function "switch_to_blog" but it doesn't seem to be doing anything at all. I call it on the site home page, "/", and then proceed with the word press loop and it is still pulling posts from the main blog, "/", instead of the blog I switched to. The function is returning true to say that the switch was successful, yet its not pulling posts from the right blog. Why isn't this function working?
<?php switch_to_blog(8);
if(have_posts()) {
while(have_posts()) {
the_post(); ?>
...
<?php }
}
?>
justinph
Member
Posted 14 years ago #
You have to query_posts() and start_wp(), like this:
<?php switch_to_blog(8);
query_posts();
start_wp();
if(have_posts()) {
while(have_posts()) {
the_post(); ?>
...
<?php }
}
?>