0

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.

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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