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.

I have a multisite setup, with the main site being the company web site and a couple other blogs that will have different themes.

I want to pull in posts from one or the other blog onto the home page of the main blog.

What is the best way to accomplish this?

Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

There's a function to get one post from one blog, but that's it:

<?php 
  $post = get_blog_post( $blog_id, $post_id ); 
  echo $post->ID;
?>

If the blog has only one author you could also use get_most_recent_post_of_user. But I think the best way is to fetch the feed using fetch_feed():

$rss = fetch_feed('http://feed.url');
// Figure out how many total items there are, but limit it to 5. 
$maxitems = $rss->get_item_quantity(5); 
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);

foreach ( $rss_items as $item ) { // Loop
    echo $item->get_title();
    echo $item->get_content();
}

It uses the Simplepie API, I recently wrote an article about that Display RSS Feed in WordPress.

share|improve this answer
    
Thanks Mario. Working great so far. –  evanmcd Jul 29 '11 at 19:13
add comment

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.