Tips, WordPress

Displaying an RSS Feed on a WordPress Page

If you’re looking to display an RSS Feed on a WordPress page it can actually be done in less than 5 minutes.

If you’re looking to hard-code this into one of your page templates then paste the following code where you want it.

<?php include_once(ABSPATH.WPINC.’/rss.php’); // path to include script $feed = fetch_rss(‘http://domain.tld/your-feed/’); // specify feed url $items = array_slice($feed->items, 0, 7); // specify first and last item ?> <?php if (!empty($items)) : ?> <?php foreach ($items as $item) : ?> <h2><a href=”<?php echo $item[‘link’]; ?>”><?php echo $item[‘title’]; ?></a></h2> <p><?php echo $item[‘description’]; ?></p> <?php endforeach; ?> <?php endif; ?>

If you’re looking to use this in a WordPress page or post then you’ll need to install the Exec-PHP plugin to get the code to render.

If you have any questions or need help displaying an RSS Feed on a WordPress page feel free to leave a comment below or contact us.

Related posts