Did you ever wonder how some people are able to display ads on their rss feed? Sure, you can modify core files to do it, but that’s not a good idea at all. Here’s a clean way to insert ads (or anything) on your rss feed, without having to hack any core file.
In order to achieve this recipe, paste the code below to the functions.php file from your theme. If your theme doesn’t have a functions.php file, create it.
<?php function insertAds($content) { $content = $content.'<hr /><a href="http://www.CodeRevolution.com">Have you visited CodeRevolution today?</a><hr />'; return $content; } add_filter('the_excerpt_rss', 'insertAds'); add_filter('the_content_rss', 'insertAds'); ?>
Here, we first create a function called insertAds(), which concatenate a code containing our advertisment to the $content variable, which contains the content of the post.
Then, we use the add_filter() function to overwrite the the_content_rss() function with our insertAds() function. We use another filter to overwrite the_excerpt_rss() function as well.
That’s all, your rss feeds now displays your ads!
Credits goes to k-ny for this awesome recipe!