Insert Ads or Custom Text in RSS Feeds in WordPress

Almost every WordPress blog uses RSS feeds these days to deliver content directly to readers’ mailboxes or feed readers. Also, RSS subscribers count is an important factor in deciding the blog’s popularity.

So, don’t you think that you should find out some way to monetize your RSS feeds. Maybe you can insert some affiliate link or banner ad in it. Here’s a small snippet that helps you to add any ad banner or any custom text in RSS feeds,

function insertRss($content) {
if(is_feed()){
$content = 'text before content'.$content.'<hr /><a href=&quot;http://www.agentwp.com&quot;>AgentWordPress! Best of WordPress Tips, Themes and Plugins.</a><hr />';
}
return $content;
}
add_filter('the_content', 'insertRss');

Just paste the above code snippet in the functions.php file inside your theme folder. If you don’t see any functions.php file, then simply create one. You can edit the content part (the value of $content variable) according to your requirements.

share on twitter

Leave a Reply