Ever created a "25 Best XYZ Sites" roundup only to watch it go stale as soon as those sites publish new content? Manually linking to recent posts is tedious and outdated. As experienced WordPress developers at our agency, we've helped countless sites stay fresh by embedding live external RSS feeds directly into posts via a custom shortcode. This keeps your lists dynamic and trustworthy for readers.
To implement this, add the following code to your theme's functions.php file (we recommend a child theme or custom plugin to avoid update issues):
include_once(ABSPATH . WPINC . '/rss.php');
// Shortcode function
function readRss($atts) {
extract(shortcode_atts(array(
'feed' => '',
'num' => '1',
), $atts));
return wp_rss($feed, $num);
}
add_shortcode('rss', 'readRss');In any post or page, simply use the shortcode like this:
[rss feed="https://feeds.feedburner.com/wpbeginner" num="5"]
Replace the feed URL with your target site's RSS link and adjust the num parameter for the number of items displayed. This outputs a clean list of recent posts with links and excerpts.
Source: Smashing Magazine