Bytenap Networks

Bytenap-Network_color

WordPress comes with standard RSS feed functionality which is adequate for most users. But, if you want to add custom content or add post thumbnail to your RSS feeds, you will have to make a custom RSS feeds in WordPress.

Luckily, you can customize your RSS feed easily just by adding few lines of code. However, take note that this tutorial is not beginner-friendly, so if you want to tweak the RSS feed, first do it on a local WordPress.

Related Posts:

Also, ensure that you take the whole backup of your WordPress site prior to doing any modification to your live site.

With that being said, let’s understand what is RSS feeds and later on we will see how you can create your own custom RSS feed in WordPress.

What is an RSS Feed?

RSS stands for Really Simple Syndication. It’s really useful for bloggers who want to grow their audience as this ideal functionality allows bloggers to share their content on the other sites through feed readers.

Visitors that sign up for RSS feeds can utilize their pick feed reader to browse content, leave comments and share the posts on social media platforms.

If you want to make your content stand out, you need to create your own custom RSS feed and target specific readers.

Now, let’s see how to create a custom RSS feed in WordPress

How to Create Your Own Custom RSS Feed in WordPress?

This Guide will help you in creating a custom RSS feed with the attributes shown below:

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

Create the new RSS feed in your theme’s functions.php file. Get started by add following code snippet:

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

The above code will enable the customRSS function on your website. You will have to change the ‘feedname’ according to the name of the feed, you like to be called.

Then, you are required to make a callback function, and you can do so by adding the below displayed code:

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

The above code uses the get_template_part function to link to a separate template file. But, you can likewise put the RSS code straight into the function.

We suggest you set the slug to ‘rss‘ so as to make it simpler to navigate.

The next step is to make a feed template. Make a new file in your child theme’s folder and save the file name as slug-name.php, by using the arguments from the earlier snippet.

The following code is for template file:

<?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: You can manage and control the number of posts to be shown in your feed by changing the postCount variable. You can additionally tweak this template if you wish that your feed display images, comments, etc.

Once your done and satisfied with your feed template, save the template and head on to Settings → Permalinks which is accessible in your dashboard.

Click on Save Changes. This will flush the rewrite rules so that your feed can be display appropriately.

Last but not the least, you can access your custom feed at yourdomain.com/feed/feedname.

Conclusion

We hope that this blog post helped you create your own custom RSS Feeds in WordPress. 

Social Media

Stay Informed For Online World & Business Updates!

Scroll to Top

Linux Reseller Hosting Comparison Plan

LR-S LR-M LR-XL LR-XXL
SSD Disk
100GB
200GB
Unlimited
Unlimited
Bandwidth
Unlimited
Unlimited
Unlimited
Unlimited
cPanel Accounts
20
40
60
100
Free Migration
Free SSL Certificates
Domain Hosted
Unlimited
Unlimited
Unlimited
Unlimited
FREEBIES
350+ one click Script Installer
Weekly Backups
Free SSL Certificates
CloudFlare CDN
Domain Reseller Account
RESELLER FEATURES
Private Name Servers
WHM Panel
Client Backup Restores
Per cPanel SSH Access
ACCOUNT RESOURCES
Add-On Domains
Unlimited
Unlimited
Unlimited
Unlimited
Sub-domains
Unlimited
Unlimited
Unlimited
Unlimited
Parked Domains
Unlimited
Unlimited
Unlimited
Unlimited
Databases
Unlimited
Unlimited
Unlimited
Unlimited
FTP Accounts
Unlimited
Unlimited
Unlimited
Unlimited
CPU Core
1 Core
1 Core
1 Core
1 Core
RAM
1 GB
1 GB
1 GB
1 GB
Entry Processes
20
20
20
20
IO Speed
4 MB/s
4 MB/s
4 MB/s
4 MB/s
SERVER FEATURES
LiteSpeed Web Server
PHP v5.6 to latest
MySQL / MariaDB
Web Application Firewall
Caching
CloudFlare CDN
CloudLinux
CageFS
DDoS Protection
Server Locations
US | CA | DE
SECURITY FEATURES
DDoS Protection
Web Application Firewall
Brute-Force Protection
Brute-Force Protection
Two-Factor Authentication
Email Virus Scanner
CageFS Account Isolation
ByteNAP ASSURANCES
Uptime Guarantee
24x7x365 Support
Live Chat Support
Free Migration
Cancel Anytime
Instant Setup
AVAILABLE ADDONS
Instant SetupDedicated IP
$4.5/Mo
$4.5/Mo
$4.5/Mo
$4.5/Mo
Upgrade to Daily Backups
$5/mo
$5/mo
$5/mo
$5/mo

Managed Services

Managed Support

Get fully managed support from Experts
with Pro Active monitoring

Domain

Domain Registration

Register Domain Today

Domain Transfer

Domain Transfer are Quick, Easy &
Affordable

Email

Cloud Mail

Connect & Collaborate with Customers

Google Workspace

Create, Communicate & Collaborate

Security & Backup

SSL Certificate

Secure Your Data & Transactions with SSL Certificate

BitNinja

Secure your Webpages with BitNinja Server

Acronis Cloud Backup

Secure Data Backup for Businesses of All Sizes

Servers

Bare Metal Servers

Solid Performance Bare Metal Server

GPU Servers

Next-Generation GPU Server

Clearance Servers

Stable Clearance Dedicated Server

Cloud VPS

Linux VPS

Get Faster Loading Speed with Linux VPS Hosting

Windows VPS

Leading Windows VPS Hosting

Managed Linux VPS

Powerful Managed Linux VPS Hosting

Managed Windows VPS

Realiable Managed Windows VPS Hosting

Hosting

Linux Hosting

Feature Packed Linux Hosting

Windows Hosting

Stable Windows Hosting Server

Wordpress Hosting

Best & Secure WordPress Hosting

Linux Reseller Hosting

Start Business with Linux Reseller Hosting

Windows Reseller Hosting

White-label Windows Reseller Hosting