Filed under Make Money Online

I’ve been searching for a while how to integrate banners ads into WordPress RSS feed. I know that if you use OpenAds image tag invocation within your posts it works, but I’d rather have the ad code inserted dynamically.

I’ve finally found some way to do but I’ll be experiencing for a few days to make sure it works properly.

To implement this, WordPress must be installed on the same webserver as OpenAds. You might also encounter some problems related to an “open-basedir” restriction if OpenAds isn’t installed on the same hosting account as your WordPress blog.


The first thing you have to do is to create a publisher zone in OpenAds. This zone will be used to display ads only in your RSS feed. Then add an HTML ad to your OpenAds inventory and link it to the newly created zone.

I don’t know if you can use javascript ads but I wouldn’t be surprised if it didn’t work well in some RSS readers.

Next, download the file located in [wordpress root directory]/wp-includes/feed-rss2.php from your website (using an FTP client like Filezilla).

Before editing it, please make a backup copy. Oh and make a backup copy. Just in case anything goes wrong.

Find the line that reads:

<content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>

Now copy the local mode tag invocation code for your OpenAds zone to your clipboard. You must now paste it between

<content:encoded><![CDATA[

and

<?php the_content() ?>]]></content:encoded>.

Save the file and upload it back on your webserver. If things aren’t displayed properly, simply tweak the HTML code from your ad (in OpenAds). And if you’ve broken WordPress, upload your backup copy back.

Also keep in mind that this does not behave like a plugin which means, if you update your WordPress installation, you’ll have to modify feed-rss2.php again.

I’ll try it for a few days and see if it works with Feedburner. Subscribe up to my RSS feed and let me know how it displays!


Related Posts

Comments (0) Posted by Stephane on Friday, November 30th, 2007


You can follow any responses to this entry through the magic of "RSS 2.0" and leave a trackback from your own site.

Post A Comment