Features: How to build custom RSS feeds? | Inoreader

How to build custom RSS feeds?

RSS is the calling card for any website. It’s one of the first pieces of code at the time the Internet was still looked at suspiciously and even called fad, and also defined the early years of blogging. It’s why so many website platforms still support and auto-generate RSS feeds for their sites.

Blogger, Tumblr and even YouTube channels have their own built-in RSS feeds, but the champion among them all is WordPress. Not only for the fact it’s the dominating force on the Internet, but the flexibility the platform allows its users to create and customize their sites’ RSS feeds.

Why need an RSS feed for your website?

Really simple syndication (RSS) lends a helping hand to those readers who have a long reading list and a ravenous appetite for content whether it’s for work or for a research project in their spare time. Through RSS, users eliminate menial, repetitive tasks in going through their roster of sites by syndicating their content to a single feed.

RSS users are exactly the readership you want to attract:

  • Attentive to the content you publish and likely to engage through comments or social media sharing;
  • Curious to follow your content post after post;
  • Organized in their approach to reading and looking for a solution to the oversubscription to newsletters;

Doesn’t that sound like the definition of the perfect reader? Building an audience and retaining it are a long-term project and you have to arm yourself with every possible tool to speed the process along. RSS might seem outdated, but they still have their value as readership retainers. Numbers may be lower compared to Twitter accounts with high follower numbers and high engagement, but it’s the quality of readership that matters!

It’s not uncommon for people to share and retweet solely based on the title without having even opened an article. I’ve done it. You probably have also done it.

The benefits of having RSS feed for your site

RSS readers have found a second-life as a productivity tool among digital writers and marketers, so you shouldn’t count out RSS as a technology, yet. Yes, browsers are cycling out RSS (look no further than Mozilla, which stopped RSS support back in 2018), but RSS has long relocated into the world of mobile applications.

As a result, RSS is rebuilding its user base and what distinguishes these users is their commitment to blogs and news sources. Adding a website to your RSS feed means your reader is loyal and truly wants to receive more of your content. In terms of loyal readership, that’s the gold standard.

What’s more, current RSS readers have built-in social media sharing, so they’re also equipped to spread your content easily with a single click. Social media might be useful in getting a headline viral, but the Internet is fickle. You’re less likely to hold onto views in such numbers over time due to market oversaturation and the mysterious ways algorithms recommend content to users, even if they’re following you.

RSS has no algorithm. It’s interested in delivering content when it’s published and in the order it’s published.

What is a custom RSS feed?

To answer this question, we have to touch upon what a default RSS feed is. For WordPress this is the feed generated upon the creation of the site and can be accessed by typing a specific tag at the end of a site’s URL. Here are common formats:

  • /rss/
  • /feed/
  • /feed/rss2/
  • /feed/rss/
  • /feed/rdf/

Default feeds showcase all content posted in chronological order and formatted in a standard way. Custom RSS feeds allow you to group types of content together for the users’ convenience. Do you want certain categories to have their own RSS feeds? Do you want to group content by who wrote it, if your site values and promotes individual creators? Do you want to play around with how posts appear in an RSS reader?

You can do it all and more.

How to create custom RSS feeds in Wordpress?

WordPress values RSS as a fundamental feature for the betterment of user experience. To that end, generating RSS feeds is supported in a variety of ways. Apart from the auto-generated feeds that come with every website, site owners have the capability to create feeds through plug-ins. Whether it’s Category Specific RSS feed Subscription or Better RSS Feed, download the plug-in that best matches your needs and install. It can’t be any simpler.

But we want to swim away from the shallows and go into the deep. WordPress has endured because users have immense control over their themes and the same extends to RSS feeds. Maybe you’re delivering highly specific content throughout your general content schedule, and want to enable users to receive only those posts. Whatever your motivation or vision is, you can achieve it, but you have to know what you’re doing. Advanced users only (though if you want a challenge might as well start somewhere)!

Those unafraid of getting their hands dirty by code can program their own RSS feed from scratch and this is what we’ll guide you through.

Beware! Always backup your site before you do any maintenance whatsoever.

Create a template

Right, as we’ve said you should backup your website. Many professionals rely on a child theme folder for the particular reason of avoiding major errors occurring on the main theme. There are steps to getting to the temple – adding the feed to the functions.php file, naming it, then creating a rss.php file, which will store the template for your custom feed.

Paste this template in the rss.php file and modify it any way you see fit. One thing to note here is about the excerpts feature. You can select what excerpts to appear in the feed. Should there be no excerpts, then the feed automatically displays the first 120 words in the article.

<?php
   /**
   * Template Name: Custom RSS Template - YourCustomFeedName
   */
   $postCount = 10; // The number of posts to show in the feed
   $postType = 'post'; // post type to display in the feed
   query_posts( array( 'post_type' => $postType, 'showposts' => $postCount ) );
   $charset = get_option( 'blog_charset' );
   header( 'Content-Type: ' . feed_content_type( 'rss-http' ) . '; charset=' . $charset, true );
   ?><?xml version="1.0" encoding="<?php echo $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>
<?php // Reset Query
wp_reset_query();

Choose functionality and language

English might be the default on the Internet, but not necessarily universal. Nor should your readers be expected to speak it fluently. WordPress allows you to declare the language for your RSS feed and there’s a large list of languages to choose from. To declare the language, you need to head to the “functions.php” file and paste:

function myFeedLanguage(){
    update_option( 'rss_language', 'en' );
}
add_action( 'admin_init', 'myFeedLanguage' );

You will notice ‘en’ – this stands for English. To change it to another language, all you have to do is replace it with the code for another language. Here’s a comprehensive list of language codes.

Another popular functionality many site owners tinker with is the inclusion of post thumbnails in your feed. RSS feeds have come to include some multimedia and you can easily have the RSS feed display a thumbnail image along with the feed text unless a post doesn’t have an image, in which case nothing will be displayed. Again, you will head to the “functions.php” file and paste:

/*This code adds thumbnail feature to your custom feed*/

add_action( 'rss2_item', 'custom_thumbnail_tag' );
function custom_thumbnail_tag() {
    global $post;

    if ( has_post_thumbnail( $post->ID ) ) {
        $thumbnail = get_attachment_link( get_post_thumbnail_id( $post->ID ) );
        echo("<image>{$thumbnail}</image>");
    }
}

Filter your content

Another application of customized RSS arises when you want to direct traffic to a third-party site. In most cases, website owners do this, because they own multiple sites and want to distribute their readership. You’re likely to select the most relevant content to bridge readers over to the other and to that end you need to curate your own content.

The same principle applies when you’re linking to an important news publication or resources in your industry to augment your readers’ overall experience. Not only does it serve a real purpose, but you’re also improving your SEO by linking back to established domains with high authority. In this scenario, you’re able to use the various filtration tools available through your RSS reader to tailor the ideal RSS feed. We’re going to show you how to do this.

How to filter and customize RSS feeds in your reader?

RSS feeds can be customized on the users’ end as well, which is one of the main selling points of modern RSS readers today. Readers can select what they want to read and how they want to filter it. Inoreader runs laps around the competition with powerful customization on all levels.

Turn to filter settings to customize a single feed on a number of criteria or automate the reading process further by turning to the rules function, which integrates Inoreader with other third-party clients like OneNote and Google Drive. If you’re repurposing Inoreader as a keyword monitoring tool, then you can gain further usefulness from the regex support. Users can then receive or exclude content by category, keywords, authors or any set of criteria that you have chosen.

Integration with services like Zapier and IFTTT simplifies this process as both platforms offer its users a database with user-created commands based on triggers. You don’t need more than to just install one to get the desired effect.

Of course, you’re in a position to create your own zaps and curate a single master Superfeed, which takes the concept of automation to the next level. With the right customization, you won’t need to do any more skimming through irrelevant material. Any post trickling to your Superfeed is the one you want to read.

Get the most value out of your reading

With Inoreader, content comes to you, the minute it's available.

Create free Inoreader account