So depending on your blog, audience and purpose you may want to have the ability to display content and/or ads specifically for your RSS feed only. This comes in super-handy, especially because your RSS subscribers are typically among your most loyal followers so you may want to show them content or ads that you think best applies to them specifically. Here are two ways (with code) to accomplish this with WordPress.
1. Insert Ads Across Entire RSS Feed
Originally provided by WPrecipes.com, this snippet of PHP when placed in your functions.php file inside your theme gives you the ability to place a global ad across all posts in your RSS Feed.
function insertAds($content) {
$content = $content.'<hr /><a href="http://chasesagum.com">Have you visited ChaseSagum.com today?</a><hr />';
return $content;
}
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content_rss', 'insertAds');
Just change out what’s in the $content variable to the HTML you want for your ad.
2. Feed Only Content On a Post-By-Post Basis
This snippet of code from WPBeginner.com helps you use your functions.php file to create a new custom shortcode that you can use to display content just in your RSS feed on a post-by-post basis. Pretty dang cool. Once this code is in your functions.php file you can use [feedonly]content goes in here[/feedonly] to specify which content you only want displayed in your feed.
function feedonly_shortcode( $atts, $content = null) {
if (!is_feed()) return "";
return $content;
}
add_shortcode('feedonly', 'feedonly_shortcode');
There you go. 2 customizations you can make to your WordPress Theme today to help you provide better content to your RSS subscribers.

Leave a comment