How to create RSS feed for Wordpress? | Inoreader

How to create RSS feed for Wordpress?

But doesn’t WordPress already come with an RSS feed for my website? Why would I need to build one in the first place?

Fair questions to ask and it’s true – WordPress site templates all have their own RSS feed. These come in their own unique URL formats. Here are example formats most likely to appear, if you have permalinks enabled (there are a lot more possibilities out there):

http://example.com/feed/

http://example.com/feed/rss2/

http://example.com/feed/rss/

http://example.com/feed/rdf/

Don’t get me wrong – they get the job done, but that’s only the first layer to consider. WordPress sites come with a robust code featuring the essential and from then on out, customization falls into the hands of the creators. Initiates into the greater mysteries of WordPress can tinker and play with the code as much as they want (also applies to RSS). For those making their first steps into the WP arena, turn to the extensive library of existing plugins to achieve any purpose.

Before we move onto the more practical aspects, we have to address some key questions.

What is RSS and how to use it in Wordpress?

RSS has been part of the Internet landscape since the very beginning of the World Wide Web. It hit its heyday in the early 00s, but as a robust technology, RSS has persevered and brought forth the birth of social media, live stock exchange rates and subscriptions to podcasts and channels on video sharing platforms like YouTube. RSS stands for ‘Rich Site Summary’ or also ‘Really Simple Syndication’ and manages how users access and consume content.

Feed readers are third-party applications, which exist either as a browser-based service or a mobile application for a number of devices. Users can browse through the latest content of as many sites as they want in one location and as such, drastically reduce the manual work of visiting each site individually.

RSS doesn’t require any payment, though certain features on feed readers are paid. WordPress has good support for RSS. Every WP site comes with its own RSS feed, which users can easily find. Site owners don’t have to do anything unless they want to add more to their RSS feeds.

All you need to know about RSS feeds

RSS feeds are very much alive and widely used even today. You see this in how Google displays information for specific searches – weather updates, currency conversion rates and most relevant for 2020, the US election updates and COVID-19 statistics globally and locally.

Google does this on the basis that RSS feeds syndicates content from one source and distributes it to another. Usually, this process occurs within an RSS feed reader, but Google and other sites are able to integrate information through RSS freely.

RSS feeds are coded in XML and are found within a site’s code. These XML files are crawled and read by RSS feed readers, which add any new publication to its feed. The principles behind RSS feeds are used in social media sites such as Facebook, Instagram, Twitter, and YouTube. Follow or subscribe to a page and you receive new posts on your feed. The key difference is that RSS prioritizes a chronological order of posts.

WordPress creates default RSS feeds for your website, which are simple, rudimentary and get the job done. If you’re not particular about how your RSS feed looks or lumping all your content into one feed, then leave your site as it is. But should you want more… WordPress cooperates in bringing your vision to life.

How you can use RSS in Wordpress

With a little bit of creativity, RSS can perform multiple tasks outside its main function – enable Internet users to view content from numerous websites exported to an RSS reader. WordPress has still excellent support for RSS, even though we’re a decade removed from its zenith. Site owners are granted the ability to:

  • Create a site, which syndicates content from other online sources. All there’s to do is seek out relevant feeds to your topic of choice and import their content through RSS feeds. This is especially useful, if you’re interested in a niche topic and want to create a hub for readers who don’t want to dig around too much for the information.
  • Integrate RSS with social media platforms. This applies to both directing content from your social media pages to your site and vice versa. Have a feed of your Twitter page right on your homepage or display your latest podcast episodes, where visitors can find them. You can also share your content automatically on social media through simple automation.
  • Use RSS to feed reviews and comments from customers on your Testimonials page.
  • Display content that’s not your own, but is relevant to your audience. Perhaps you’re a site dedicated to local news, in which case it makes sense to feature live weather reports. For business sites, perhaps stock exchanges are suitable. All this can be achieved with the power of RSS.

Create a custom RSS feed for Wordpress

RSS sells curation as its core value proposition – a user-friendly way to assume control over what one reads efficiently. Users rely on RSS feed readers to downsize the enormity of content online through careful selection and automation. Reduce menial tasks and reap the benefits of just a single master feed.

Inoreader has excelled in its filtering and curation capabilities. Through Filters and Rules, you can shape feeds in any way possible through the inclusion and exclusion of topics and authors. While that’s quite useful, the main downside is that the responsibility to curate falls onto the reader, when website owners can easily do the heavy lifting.

WordPress has made it simple to build custom RSS feeds compared to other platforms and it’s an investment well worth the little time it takes to accomplish.

Use an RSS plugin

WordPress and RSS go hand in hand. The platform continues to support RSS and outside of the automatic creation of a general RSS feed, users can further supplement their website through the additional use of plugins to add elements freely. With a few simple clicks, you can enrichen the overall user experience.

Better RSS Feeds is the beautician to your RSS feed and enables adding media content to posts – a thumbnail to each post’s excerpt and full text. It gives your feed a more polished and attractive look. Not to mention you visually signal to your readers what they can expect to read in the post, which is more effective than relying on titles alone.

Category Specific RSS feed Subscription exists to spread out the overall stream of content into their specific subject matter. Turn your category tags into their own unique RSS feeds. Readers are able to better tailor the content they want to receive to their general reading interest. This plugin makes sense to install for sites with multiple posts per day that may otherwise overwhelm readers through a single RSS feed.

Lastly you can utilize the RSS support function of WordPress in the creation of an aggregator site. WP RSS Aggregator sources feeds from other sites grouped by topic and supplies readers with a steady stream of articles and news items for a specialized field of interest. This way users don’t have to curate their own RSS feeds in a feed reader, but have one major subscription.

Code an RSS feed in Wordpress

Sometimes, an auto-generated RSS feed does not live up to what your readership needs or expects from your content. WordPress solves this quite easily. A core feature is granting site owners the flexibility to create their own custom RSS as they see fit.

Rather than just targeting content by a single author or category, you can take a deep dive into a specific series of articles. Yes, it can be done, but fair warning – you should already have an inkling as to how WordPress works and done a little poking around the code beforehand.

IMPORTANT: Before you even dare write a single line of code, you better back up your website. There’s not much to this step as there are plenty of backup plugins developed for WordPress. Get UpdraftPlus and rest easy knowing you can always revert to a previous version, if things go south.

With disclaimers out of the way, it’s time to create the custom RSS feed and you do this by placing this code into the functions.php file of your website:

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

Note – you can access the functions.php file through the cPanel File Manager. Once you locate it, hit Edit and you are on your merry way.

You will see that we have emphasized on ‘newfeed’. This is going to be the name of your custom RSS feed and it’s important to remember how you wrote for the next step, which is creating the callback to WordPress.

The next line of code you need to paste is this, and you have to use the same name you’ve written for ‘newfeed’ in the previous section.

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

Save your progress and close the functions.php file.

Now, we are moving to the particulars of the RSS feed and its template. Create a new file called rss.php, which is to what the code up until now will locate. In the rss.php file, paste this template. From here on out, be as creative as you want and alter as many components as you wish to better fit your vision for the RSS code. Hit save and you are all done.

<?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 – keep in mind there are likely to be some errors that you will need to troubleshoot. Patience is your best ally during this process.

Get the most value out of your reading

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

Create free Inoreader account