How to create a WordPress custom RSS feed
Themeisle content is free. When you purchase through referral links on our site, we earn a commission. Learn More

An RSS feed is an excellent blogging tool that can help grow your audience. By default, WordPress comes with standard RSS feed functionality, which is sufficient for most users. However, if you’d like to deliver specific content or add post thumbnails to your feeds, you will need to create a custom RSS feed in WordPress.

Fortunately, you can customize your RSS feed relatively easily by adding a few lines of code. Note that this method may not be suitable for beginners as you’ll need to access your child theme’s functions.php file. However, most intermediate users should be able to follow the instructions below.

In this article, we’ll show you how to create a custom RSS feed in WordPress. We’ll also discuss why it’s useful and how you can feature content from external sources on your site with a simple plugin. Let’s go!

Understanding RSS feeds and how they can benefit your site

RSS stands for Really Simple Syndication. It’s a handy functionality that enables bloggers to share their content on other sites and via feed readers. This enables subscribers to keep track of new posts without checking each of their favorite websites manually. There are also other ways to use RSS feeds in WordPress, which we discussed in a previous article.

Visitors who sign up for RSS feeds can use their chosen feed reader to browse content, leave comments, and share posts on social media. You should be able to access your site’s feed via yourdomain.com/feed. Note that doing this will only show you the code; you need a dedicated news aggregator tool such as Feedly to see it in its full glory.

If you want to differentiate your content, you can create a custom RSS feed and target specific readers. This can be useful if your website caters to multiple niches.

You can also feature posts from external sources using our Feedzy plugin. For instance, you could aggregate content from other blogs, podcasts, or even YouTube channels and display them on your site to increase engagement.

How to create a custom RSS feed in WordPress

Unfortunately, customizing an RSS feed takes some advanced knowledge, so we would not recommend undertaking this approach unless you’re at least a little comfortable with code.

Before you proceed, it’s smart to back up your site so you can recover it if something goes wrong. When you’re ready to proceed, follow the instructions below.

This tutorial will help you create a custom RSS feed with the following attributes:

  • Post title
  • Link
  • Published date
  • Author
  • Excerpt

You can add these code snippets in one of two places:

  1. You can use the free Code Snippets plugin, which provides a convenient interface to manage these types of snippets. This is the simplest option for most people.
  2. You can edit your child theme’s functions.php file – make sure to use a child theme so that you don’t overwrite your changes when you update your theme.

To get started, add the following code snippet:

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

This will initiate the customRSS function on your site. You’ll need to change the 'feedname' accordingly, depending on what you want to call your new feed.

Next, you’ll need to create a callback function, which you can do by adding the following code:

function customRSSFunc(){
        get_template_part('rss', 'feedname');
}

This will link your feed to its own template file, which we’ll create in a moment. Note that the 'get_template_part' function has two arguments: the URL slug and the feed name. We recommend setting the slug to 'rss' so it’s easier to navigate.

Next, you’ll need to create the feed template. Create a new file in your child theme’s folder and save it as slug-name.php, using the arguments from the previous snippet (e.g., rss-feedname.php).

The code for the template file is as follows:

<?php
/**
 * Template Name: Custom RSS Template - Feedname
 */
$postCount = 5; // 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 echo mysql2date('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>

Note that you can control the number of posts displayed in your feed by changing the postCount variable. You can also amend this template if you want your feed to show images, comments, and so on.

Once you’re happy with your feed template, save it and head to Settings β†’ Permalinks in your dashboard. Click on Save Changes. This will flush the rewrite rules so that your feed can display correctly.

You should now be able to access your custom feed at yourdomain.com/feed/feedname (substituting values with your custom ones).

How to feature other RSS feeds on your WordPress website

Alternatively, another way to use RSS feeds is to feature feeds from other blogs or platforms on your website. In that case, you can use our Feedzy plugin and import content from external RSS feeds.

Once you’ve installed and activated Feedzy, go to the page or post where you’d like to feature one or more feeds. If you’re using the Block Editor, you’ll be able to add a Feedzy block and paste your desired source URL:

Adding an external RSS feed using Feedzy and the Block Editor.

In the settings area in the right-hand sidebar, you can adjust the number of feeds you want to display, caching time, and sorting order.

If you prefer to use the Classic Editor, you can use a Feedzy shortcode [feedzy-rss feeds=" source_URL"] and embed it anywhere you want the feed to appear on your site.

Alternatively, you can use a widget, which you can activate via Appearance β†’ Widgets in your dashboard:

Activating the Feedzy widget in WordPress.

You can also import RSS feeds into WordPress as posts, which we discuss in more detail in another tutorial.

Create your custom RSS feed in WordPress today

Creating a custom RSS feed in WordPress can be tricky. However, if you’re comfortable with code, you can easily add different feeds and start delivering unique content to your readers.

In this post, we’ve shown you how to create a custom RSS feed in WordPress. You’ll need to add some custom code snippets and create a template to customize your feed’s appearance, so only attempt this method if you have the necessary skills. Alternatively, to feature external feeds on your site, you can use Feedzy without any coding knowledge.

For some other ideas on how to use RSS feeds in WordPress, check out these posts:

Do you have any questions about custom RSS feeds? Let us know in the comments section below!

Free guide

5 Essential Tips to Speed Up
Your WordPress Site

Reduce your loading time by even 50-80%
just by following simple tips.

Download free guide

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!