Picture of Simon Wright

Simon Wright

Simon is an expert writer and with a passion for content and curation.

Table of contents

Building a Custom WordPress RSS Feed in 4 Easy Steps

In this article, we'll show you how easy it is to create your own custom RSS feed, enabling you to distribute your content across multiple platforms. We'll also take a brief look at what RSS is, how a custom RSS feed can benefit your WordPress site, and how to create one for your WP RSS Aggregator imported items.
WordPress Custom RSS Feed

Need a custom RSS feed for your WordPress blog or website? We’ve got your back!

Did you know that with an RSS feed, you can automatically update your website readers whenever you share new content? So not only can they help you share content easily, but they can also help enhance your online reputation and grow your email lists. Sadly, default WordPress RSS feeds do come with one major limitation – you cannot customize the content they include.

In this article, we’ll show you how easy it is to create your own custom RSS feed in WordPress, enabling you to distribute your content across multiple platforms. We’ll also take a brief look at what RSS is, how a custom RSS feed can benefit your WordPress site, and how to create one for your WP RSS Aggregator imported items.

What Is a WordPress Custom RSS Feed?

WordPress Custom RSS feeds are an easy way to stay automatically updated with your favorite websites’ latest content as soon as it is published. That is super-convenient, as you no longer need to manually visit the sites to check if new content is available.

Moreover, if you have your own WordPress website or blog, adding a custom RSS feed to it allows you to circulate your content to your subscribers easily.

At its core, it is essentially a file format that allows users to subscribe to receive updates from various sources.

Why Do You Need a WordPress Custom RSS Feed?

Having a custom RSS feed on your WordPress site is an excellent idea for several reasons, including

Increase content visibility and drive more traffic to your website

As RSS feeds broadcast your content far beyond just your website, more people will be aware of it, making them more likely to visit it.

Publish custom content on multiple platforms

An RSS feed can help push your content to various platforms simultaneously, for example, social media such as Twitter RSS, email newsletters, etc.

Grow your email list

You can combine an RSS feed with an email service like MailChimp to help build your email list. As any marketing expert will tell you, your email list is one of your most important assets.

Increased SEO

Google and most other search engines rank websites that are active with fresh, original content higher in search results compared to old, stale sites that have stale, outdated content. An RSS feed will help make your website stand out to search engines as one people are interested in and interacting with.

Publish content even when your site is down

In the unfortunate event that your WordPress site suffers an outage, a custom RSS feed will allow you to continue publishing content elsewhere, such as on social media and feed readers.

Why Use a WordPress Custom RSS Feed?

When you create a website using WordPress, it does come with built-in default RSS feeds. However, unlike a regular RSS feed, custom WordPress RSS feeds give you control over the content you share in the feed. That makes them ideal if you want to share only specific content with your readers or for adding post thumbnails to your feeds.

How Do I Create a Custom RSS Feed in WordPress?

Creating custom WordPress RSS feeds generally involves adding code to the functions.php file of your WordPress installation.

If you’re running a news aggregator website and want to create a custom RSS feed of your imported content, you can do this using a plugin such as WP RSS Aggregator.

We’ll now take you through both methods.

Method 1: Creating custom WordPress RSS feeds using code

The traditional method of adding a custom RSS feed entails inserting some new code into the functions.php file of your WordPress website. Here’s a brief overview of the process:

Warning: this method is suitable only for people experienced with coding who thoroughly understand the WordPress software.

Before making any changes in the backend, be sure to make a backup of your site or work in a staging environment.

It is possible to include a variety of elements in your custom RSS feed. However, for the sake of this overview, we will be adding just the following:

  • Article title
  • Hyperlink to the full article
  • Date the article was published
  • Author
  • Excerpt

Step 1 – Activate your site’s customRSS function

The following snippet must first be added to the functions.php file of your website’s child theme. We add it to the child theme to ensure that changes are not lost whenever you update the theme. The snippet can be added either manually or using a plugin such as Code Snippets:

add_action(‘init’,’customRSS’);
function customRSS(){
        add_feed(‘feedname’,’customRSSFunc’);}

This code activates your site’s customRSS function. It will be necessary to adjust the ‘feedname’ to reflect the URL you want for the new feed, e.g., yourdomain.com/feed/feedname.

Add the following code (either manually or using a plugin as mentioned in Step 1 to your child theme’s functions.php. This creates the callback function needed to produce the required feed:

function customRSSFunc(){
        get_template_part(‘rss’,’feedname’);
}

The purpose of this code is to link your feed to the template file, which we will create in the next step.

Please be aware that the ‘get_template_part‘ function uses two arguments: the URL slug and the feed name. We strongly suggest setting the slug to ‘rss‘ to allow for easier navigation.

Step 3 – Create the template file

Now, it is time to make the feed template. This is done by creating a new file in your site’s child theme using the arguments from the previous snippet, e.g., rss-feedname.php. Save the file as slug-name.php.

This is the code you need to add for the template file:

<?php
/**
* Template Name: Custom RSS Template – Feedname
*/
$postCount = 6;// The number of posts to show in the feed
$posts = query_posts(‘showposts=’.$postCount);
header(‘Content-Type: ‘.feed_content_type(‘rss-http’).’; charset=’.get_option(‘blog_charset’),true);
echo ‘<?xml version=”1.0” encoding=”’.get_option(‘blog_charset’).’”?’.’>’;
?>
<rss version=" 2.0"
        xmlns:content=”http://purl.org/rss/1.0/modules/content/”
        xmlns:wfw=”http://wellformedweb.org/CommentAPI/”
        xmlns:dc=”http://purl.org/dc/elements/1.1/”
        xmlns:atom=”http://www.w3.org/2005/Atom”
        xmlns:sy=”http://purl.org/rss/1.0/modules/syndication/”
        xmlns:slash=”http://purl.org/rss/1.0/modules/slash/”
        <?php do_action(‘rss2_ns’);?>>
<channel>
        <title><?php bloginfo_rss(‘name’);?>-Feed</title>
        <atom:link href=”<?php self_link();?>”rel=”self”type=”application/rss+xml”/>
        <link><?php bloginfo_rss(‘url’)?></link>
        <description><?php bloginfo_rss(‘description’)?></description>
        <lastBuildDate><?php echomysql2date(‘D, d M Y H:i:s +0000’,get_lastpostmodified(‘GMT’),false);?></lastBuildDate>
        <language><?php echo get_option(‘rss_language’);?></language>
        <sy:updatePeriod><?php echo apply_filters(‘rss_update_period’,’hourly’);?></sy:updatePeriod>
        <sy:updateFrequency><?php echo apply_filters(‘rss_update_frequency’,’1’);?></sy:updateFrequency>
        <?php do_action(‘rss2_head’);?>
        <?php while(have_posts()):the_post();?>
                <item>
                        <title><?php the_title_rss();?></title>
                        <link><?php the_permalink_rss();?></link>
                        <pubDate><?php echo mysql2date(‘D, d M Y H:i:s +0000’,get_post_time(‘Y-m-d H:i:s’,true),false);?></pubDate>
                        <dc:creator><?php the_author();?></dc:creator>
                        <guid isPermaLink=”false”><?php the_guid();?></guid>
                        <description><![CDATA[<?php the_excerpt_rss()?>]]></description>
                        <content:encoded><![CDATA[<?php the_excerpt_rss()?>]]></content:encoded>
                        <?php rss_enclosure();?>
                        <?php do_action(‘rss2_item’);?>
                </item>
        <?php endwhile;?>
</channel>
</rss>

It is possible to configure how many posts your feed will display simply by changing postCount from 6 to however many you require. Moreover, it is also possible to amend the template to display comments, images, etc., in your feed.

Save the template once you have configured it to include the items you want to display in your feed.

Step 4 – Reset the rewrite rules and view the new custom WordPress RSS feed

Finally, you need to reset the rewrite rules. Do this by going to the Settings section of your WordPress admin dashboard, selecting Permalinks, and clicking on Save Changes. Doing this will ensure that the new feed will display correctly.

Using the custom feed URL created in Step 1, you can now view your custom WordPress RSS feed in action.

Method 2: Creating a Custom RSS Feed in WordPress of Imported Feed Items with WP RSS Aggregator

WP RSS Aggregator, while allowing you to import items, also lets you create a custom RSS feed of your imported feed items. Best of all, you don’t need any coding knowledge whatsoever, as the plugin takes care of all that for you.

Note that when used with the Feed to Post feature, the custom RSS feature will also show items imported as posts (or any other custom post type). In short, if an item has been imported by WP RSS Aggregator in any way, it will be included in the custom RSS feed.

Making a custom RSS feed in WP RSS Aggregator could not be simpler:

  1. Go to RSS Aggregator > Settings > Custom Feed.
  2. Add your preferred Custom feed URL.
  3. Name the feed with the Custom feed title.
  4. Limit the number of feed items to include with the Custom feed limit.
WordPress Custom RSS feed

Your RSS feed will now be found at your custom feed URL set up in step 2 above. In this example, my RSS Feed would be: http://www.your-site.com/wprss

Categories

If you’re using the Categories add-on, WP RSS Aggregator will automatically create a separate custom RSS feed for each feed source category.

For example, if you have 3 sources categorized like so:

  1. Feed A in category “News”
  2. Feed B in category “Blogs”
  3. Feed C in category “Sports”

Then your site will have 3 custom feeds:

  • your-site.com/wprss/news
  • your-site.com/wprss/blogs
  • your-site.com/wprss/sports

The custom feed URL set up in the previous section will affect all the above custom feeds.

You are now free to use your RSS feed/s wherever you want! As new feed items are automatically imported into your site through WP RSS Aggregator, the RSS feed will be continuously updated.

Conclusion

Whether you’re managing a website with your original content, or imported content through WP RSS Aggregator, custom RSS feeds can be of great help. They can be used to back up your site, publish content on multiple platforms, build your email list, get more traffic and exposure and even increase your SEO!

WP RSS Aggregator makes it extremely easy to create custom RSS feeds for your imported items. Simply adjust a few settings on your Settings page and you’re good to go. Remember, categorizing your content using the Categories add-on automatically generates custom RSS feeds for each category – helping you keep everything organized.

To get the free core version of WP RSS Aggregator, click here, or here to purchase one of the premium plans.

Article by

Article by

Share the Post:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles