WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a feed of the most recent 10 posts from 5 different feeds all combined into one list. I found a way to combine the feeds but have not been able to easily limit them to 10 and sort them by date.

Can someone point me in the right direction? Thanks!!!

<?php $rsslist = array(

$feedlist = array();
foreach ( $rsslist as $rssurl ) $feedlist []= fetch_feed( $rssurl ); /* store in feed array for later access */

$current_item_cycle = 0;
while ( sizeof($feedlist) ) { /* while feedlist is not empty */ 

    foreach ( $feedlist as $index => $feed ) { /* cycle through each feed */

        if (!$item = $feed->get_item($current_item_cycle++)) unset($feedlist[$index]); /* if feed has not more items unset */

        else /* echo it out */ { ?>
            <?php echo $item->get_date('j F Y | g:i a') . $item->get_permalink(); ?>
        <?php }
} ?>
share|improve this question
I found these instructions on SimplePie but have not been able to merge them together to get it working: simplepie.org/wiki/tutorial/… – Tim Bowen Nov 21 '12 at 22:33
up vote 1 down vote accepted

This code should work. I commented out one of your feeds. When I uncomment it, it stops sorting things correctly. It seems that there is something wrong with it. It doesn't get formatted in the browser correctly like the rest either.

$rsslist = array(

// Fetch all of the feeds into a simplePie mashup
$rss = fetch_feed($rsslist);
// Set the max items to either 10 or all items if there are less than 10
$maxitems = $rss->get_item_quantity(10);

// Get the items (0-10)
$rss_items = $rss->get_items(0, $maxitems); 

// If there are no items, output that
if ($maxitems == 0) {
    echo '<li>No items.</li>';
// Otherwise loop over the items
} else {
    foreach ( $rss_items as $item ) { ?>
        <?php echo $item->get_date() . $item->get_permalink(); ?>
share|improve this answer
This is not working for my feeds. Im pulling from 3 (to 6) wordpress sites, all identical (same theme, different content) but no matter what I do I cannot merge and then sort by date. I get the first X of one blog, followed by the first X of the second blog and so on. Is there something wrong with these feeds: loosescrewtattoo.com/?feed=rss, jessesmithtattoos.com/?feed=rss, jasonstephan.com/?feed=rss – rugbert Oct 31 '13 at 11:41

Your Answer


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.