Random post from an RSS feed
-
Hi
I’ve been playing around with this for over an hour and I’ve searched for clues but no luck. I think I’m just lacking some basic PHP knowledge to solve this.
I have the following code working fine for me:
<?php include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $feed = fetch_rss('FEED-URL'); // specify feed url $items = array_slice($feed->items, 0, 3); // specify first item and duration ?> <?php if (!empty($items)) : ?> <?php foreach ($items as $item) : ?> <a href="<?php echo $item['link']; ?>"><?php echo $item['description']; ?></a> <?php endforeach; ?> <?php endif; ?>
This gives me three latest posts. How do I keep the selection to 3 items but have it be random posts?
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Random post from an RSS feed’ is closed to new replies.