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.wprecipes.com">Have you visited WpRecipes 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!
One Response
Thanks for this. I’m testing it out on a site right now. The code was a bit different for a site built on the Genesis framework. But the general idea seems perfect.
Trackbacks: