How to create an RSS Feed in WordPress

Overview: Create RSS Feed in WordPress

WordPress comes with default RSS feeds built into the website builder. WordPress can generate feeds for all your website posts as well as corresponding comments on default. WordPress has vast plugins that make it easy to create new RSS feeds as well as modify existing ones. The default feeds which are added to website pages tend to be enough for most people; however, you can customize the feeds accordingly. 

Creating custom WordPress RSS feeds

If you are interested in creating custom WordPress RSS feeds from scratch; you’ll need to move beyond the beginner WordPress user level. Before you get started, create a complete site backup to avoid losing critical site data.

To get started, create a new feed in your theme’s “functions.php” file. Alternatively, you can do this in a site-specific plug-in. To trigger the custom RSS function which adds a new feed, use the code below;

After adding a new feed, you must create a callback function to generate the required feed. Use the code displayed below in your theme’s “functions.php” file or site-specific plug-in. 

The purpose of the code above is linking to a separate template file via the get_template_part function – keeping functionality separate from the layout. The code can also be used directly. The get_template_part has a slug and name argument that simply “tells” WordPress to look for specific file templates. 

It is advisable to define the slug to correspond to the type of feed being created – RSS in this case. The name should match the feed name configured earlier. After “telling” WordPress to search for the feed template, you can proceed and create it using the code below;

The above code will generate a custom WordPress RSS feed that can be amended as you wish to display any kind of information required from comments to post images. The post count variable in the code allows you to control the no. of posts displayed in your feed. The excerpt_rss function displays excerpts for every post. Posts without excerpts will show the first 120-words of content.

Displaying the WordPress RSS feed

To display your new custom feed, you should proceed and flush WordPress rewrite rules. To do this, login to WordPress admin then click on permalinks under settings. Proceed and save the changes to flush the rewrite rules. 

Your custom RSS feed can be accessed by visiting: yourdomain.com/feed/feedname. Your feedname is the name given to your add_feed function.

RSS feed plugin: An easier alternative to creating custom WordPress RSS feeds

The above guide on creating a custom RSS feed in WordPress can be complicated to a person with beginner WordPress knowledge. If that sounds like you, installing an RSS feed plugin is a better option.

WordPress RSS Feed Retriever is a great alternative to customizing WordPress RSS feeds from scratch. The plugin fetches a feed/s and displays them using a short code. Simply; copy and paste, replace the URL among other properties, as you wish.

Installing the WordPress RSS Feed Retriever is easy. Simply download the zip file to your WordPress directory plugins, unzip the file and activate the plugin via your WordPress plugins menu. Proceed by using example codes anywhere in your website content. You can change the URL among other properties as you wish.

Benefits of using an RSS feed plugin to create an RSS feed in WordPress

The RSS Feed Retriever has notable benefits that include, but aren’t limited to; easy setup and unmatched control on display. You can control how you display feed content, i.e. as an excerpt or entirely. You can control excerpt word count, add a “read more” link and display feeds as you wish using a short code including text widgets. 

There are no limits to the number of feeds when using the RSS Feed Retriever. Other notable benefits revolve around simplicity and speed when creating feeds. You can also control item order, put multiple feeds in one list, set cache time and much more!

This RSS feed plugin is also lightweight which ensures your website speed remains optimal. You can use the RSS feed retriever to create custom news aggregators. The plugin can also be used to create and post RSS parsing feeds on any site page/s you choose.