Family Best Time >> Electronics

How to embed an external RSS feed in WordPress posts via Shortcode

Have you ever seen showcases like 25 Best XYZ Sites to Follow? These tutorials usually have the name of the site, the screenshot of the site, a short description, and the list of recent posts. The main problem with those posts is the list of recent posts becoming stale due to most authors manually creating those links at the time of writing. That post is really out of date as soon as any of those other sites post a new post. In this article, we'll show you how to embed an external RSS feed into WordPress posts via a shortcode, so you can keep your list posts relevant.

The first thing you need to do is open the functions.php topic. file and paste the following code:

// Este archivo es necesario para poder usar la función wp_rss (). include_once (ABSPATH.WPINC. '/ rss.php'); función readRss ($ atts) extracto (shortcode_atts (array ("feed" => 'http: //', "num" => '1',), $ atts)); devuelve wp_rss ($ feed, $ num); add_shortcode ('rss', 'readRss');

Now all you have to do is use this shortcode when writing a post:

[rss feed = "http://feeds.feedburner.com/wpbeginner" num = "5"]

Make sure to change the feed URL in the shortcode to whatever you want. You can also adjust the number to your liking.

Source:Smashing Magazine