This blog has moved to http://teabass.com

There will be no more posts or comments on this site, please update your bookmarks and feeds to http://teabass.com.

Showing adverts only on old Wordpress blog posts

Wednesday, October 1st, 2008

I’ve just added a little change to the theme here on Teabass, posts that are older than 30 days now show a small google adsense banner below the post.

The idea behind this is that most regular readers won’t click on the adverts so it’s pointless showing them, but I still receive quite a lot of traffic on the old posts from search engines.

The code to do this is pretty simple but I couldn’t find anyone else who had blogged about it on google so I thought I’d share it:

<?php if ((time() - 2592000) > get_the_time('U')) : ?>
*Your advert code here*
<?php endif; ?>

This must be called from within “The Loop” so the get_the_time() method works. To change the delay (this one is 30 days) just change the number of seconds that is subtracted from time().

Hopefully this will help you monetize your content without pissing off your regular readers, enjoy!

3 Comments so far »

  1. Nice idea! Monetize your blog without pissing off the regulars :)

    George Palmer on October 1, 2008 3:16 pm

  2. Awesome! Thanks for this!

    Jonathan Blundell on October 1, 2008 3:24 pm

  3. No problem guys, it’s not quite as elegant as it could have been in rails:

    <% if @post.created_at < 1.month.ago %>
    *Your advert code here*
    <% end %>

    but it gets the job done until I get round to finishing bumble.

    Andrew on October 1, 2008 3:31 pm


Leave a Comment