WordPress includes robust default RSS and Atom feeds that you can enhance with custom content, like post thumbnails. While standard feeds work for most sites, custom RSS feeds allow precise control over delivered content. As experienced WordPress developers, we've customized feeds for countless sites—here's how you can do the same.
Important: This guide is for intermediate to advanced users. Beginners, test on a local setup first. Always back up your live site fully before proceeding.
We'll create a custom feed displaying just these elements: Title, Link, Publication Date, Author, and Excerpt.
First, add this to your child theme's functions.php or a site-specific plugin:
add_action( 'init', 'customRSS' );
function customRSS() {
add_feed( 'feedname', 'customRSSFunc' );
}This registers your feed at yourdomain.com/feed/feedname. Note the 'feedname'—you'll use it throughout.
Next, define the callback function:
function customRSSFunc() {
get_template_part( 'rss', 'feedname' );
}The get_template_part() function loads a dedicated template. WordPress searches in this order:
wp-content/themes/child-theme/rss-feedname.phpwp-content/themes/parent-theme/rss-feedname.phpwp-content/themes/child-theme/rss.phpwp-content/themes/parent-theme/rss.phpCreate rss-feedname.php in your active (child) theme folder with this code:
<?php
/**
* Template Name: Custom RSS - Feedname
*/
$postCount = 5; // Number of posts to show
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' ) . '"?>' . "\n";
?>
<rss version="2.0"
xmlns:content="https://purl.org/rss/1.0/modules/content/"
xmlns:wfw="https://wellformedweb.org/CommentAPI/"
xmlns:dc="https://purl.org/dc/elements/1.1/"
xmlns:atom="https://www.w3.org/2005/Atom"
xmlns:sy="https://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title><![CDATA[<?php bloginfo_rss( 'name' ); ?>]]></title>
<link><?php bloginfo_rss( 'url' ); ?></link>
<description><![CDATA[<?php bloginfo_rss( 'description' ); ?>]]></description>
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_lastpostmodified( 'GMT' ), false ); ?></pubDate>
<language><?php bloginfo_rss( 'language' ); ?></language>
<generator><?php bloginfo_rss( 'version' ); ?></generator>
<?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><![CDATA[<?php the_author(); ?>]]></dc:creator>
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
</item>
<?php endwhile; wp_reset_query(); ?>
</channel>
</rss>This generates a valid RSS 2.0 feed. Adjust $postCount or add elements like images. the_excerpt_rss() shows manual excerpts or auto-generates from the first 120 words.
Flush rewrite rules: Go to Settings > Permalinks and click Save Changes. View at yourdomain.com/feed/feedname.
Validate with the W3C Feed Validator.
add_feed().global $wp_rewrite; $wp_rewrite->flush_rules(); after add_feed() in customRSS(). Reload site, then remove immediately.functions.php: function rssLanguage() { update_option( 'rss_language', 'en_US' ); } add_action( 'admin_init', 'rssLanguage' );. Load admin, then remove. Or edit wp_options table directly.This method ensures reliable, customized feeds. Share your use case in the comments—we're here to help refine it.