Welcome to our “RSS Tricks” series of tutorials! We’re going to be posting a new RSS-related tutorial every week for the next 8 weeks, so here it goes.

In this tutorial we’ll be showing you how to insert ads, or anything else for that matter, into your RSS feed.

This method will enable you to insert any adverts or other content into your RSS feeds without having to touch any core files. It can be a good way to promote certain products or services, but use it wisely. Adding too many ads (or any other unrelated content) could put off subscribers.

The Fix

All it takes to insert new content into your RSS feed is to add a few lines of code to your theme’s functions.php file. If your theme doesn’t have one, you can create it yourself.

So once you’ve opened the functions.php file, just add in the following code:

function insertAds($content) {
    $content = $content.'<hr /><a href="http://www.wpmayor.com">Have you visited WP Mayor today?</a><hr />';
    return $content;
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content_rss', 'insertAds');

That’s it. Your RSS feed now displays the ads you chose.

How It Works

Let’s go through this bit by bit.

First we created a new function called insertAds() , inside which we concatenated the HTML of the actual advert we want to include in the RSS feed to the $content  variable (which contains the original content of the post).

Next we just use the add_filter()  function to add our newly created insertAds()  handler to the the_content_rss  filter . The same is done for the the_excerpt_rss  filter too.

Source: WP Recipes

Published by Mark Zahra

Project Manager - WP RSS Aggregator


  1. I noticed when adding links using this code, the links don’t work in Mad Mimi. Works in Feedburner and MC fine.

  2. Thanks for letting us know Brad. I hadn’t heard of Mad Mimi before but I’ll check it out.


  3. I’m not a techie, where exactly do I place the adsense code?

  4. Hmm, good idea but the problem is this.
    When I insert an ad with this method the ad gets appended to every post on the rss feed. Which is a bit annoying for the subscriber.
    I thought it would be like, every 3rd or 4th item in the feed would be an ad. I wonder if there’s a way to do this?


Leave a Reply to John Cancel reply

Your email address will not be published. Required fields are marked *