Forums

Randomize RSS feed display on sidebar? (3 posts)

  1. shoshanna
    Member
    Posted 1 year ago #

    I have a blog that's pulling RSS feed entries from a different WordPress installation and displaying them on a sidebar. I'd like to randomize the entries in the RSS feed so that they don't always display in the same order.

    Here's the current code that's working, just not in random order:

    <?php include_once(ABSPATH.WPINC.'/rss.php'); // path to include script
    
    $feed = fetch_rss('FEED_URL_HERE'); // specify feed url
    $items = array_slice($feed->items, 0, 10); // specify first and last item
    ?>
    
    <?php if (!empty($items)) : ?>
    <?php foreach ($items as $item) : ?>
    
    <p><a href="<?php echo $item['link']; ?>"><?php echo $item['description']; ?></a></p>
    
    <?php endforeach; ?>
    <?php endif; ?>
  2. shoshanna
    Member
    Posted 1 year ago #

    Any ideas on this one? Is it possible?

  3. shoshanna
    Member
    Posted 1 year ago #

    Found it! I just added "/?orderby=rand" to the end of the feed URL and that did it.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags