Time Delayed Blog Ads On Your Post

I like a clean blog layout. I'm pretty much anal about it. So naturally it would be hardpressed for me to start machine gunning my blog with ads like a lot of blogs out there. After all, as anyone who earned more than a buck from it would tell you that it's about where you place it rather than how much is on in the first place.

I got the idea from Micheal who is also the creator of the awesome Bad Behavior spam filter. What he's done and what I followed suit is to place the least amount of ads on our blog for a certain period of time. After that time, the ads will come out.

It's good for those of us who don't want a cluttered single post and always tend to refer people back to our old posts to read. Since I've been getting quite a few people that have asked me how I did it, I thought I might explain it in greater detail here. What you do is basically ad this to your single post template:

<?php $days_since = floor((date('U') - get_the_time('U')) / 86400); if($days_since > 7) : ?>
"Insert ad code here"
<?php endif; ?>

*Note: To deal with the automatic smiley conversion, I put a space between ":" and "?". Just remove the space if you copied the entire code from here.

Now, you can pretty much guess that I'm running Wordpress for this, but on the upside this works for all blogs that run on PHP and it's pretty flexible too.

One is that while my ads are set to come out on my single posts after 7 days, you can set it to come out whenever you want or even disappear after a set amount of days. All you have to do is edit the number "$days_since > 7″ to whatever day you want. Altering the ">" to "<" will set it to days earlier than the set amount of days so whatever you put will only come out for those few days.

The other thing here is that whatever you insert in between the code doesn't necessarily have to be ads, it can be anything you want. Other text, javascript...etc. The possibilities are only limited to your imgination. But in this case, I use it for my adsense and it works like a charm. You can see it in action on my blog if you compare any recent posts to posts later than 7 days.

So there you have it. I hope you can put it to good flexible use. Maybe even develop a Wordpress plugin from it, who knows? If you do have any problems though. Let me know and we'll see what we can do with it.

0 Trackback and Pingbacks: »

5 People Said A Couple Of Things: »

  • GravatarChickyBabe wrote from  Australia on June 4, 2006 at 15:36 and said:

    No exactly a wordpress question but I can see you got the cocomment thingy working with my blog’s pop ups. Did you have to tweak anything?

    Comment Permalink

  • GravatarKamigoroshi wrote from  Australia on June 4, 2006 at 19:27 and said:

    Not really no. I manually entered the permalink and the titles into the cocomment everytime I post a comment on your blog. Tedious, but worth it. :)

    Comment Permalink

  • GravatarChickyBabe wrote from  Australia on June 4, 2006 at 20:18 and said:

    Hmm…sorry :(

    Comment Permalink

  • GravatarKamigoroshi wrote from  Australia on June 4, 2006 at 20:21 and said:

    For what? Cocomment’s inability to talk to Blogger’s comment popups? It’s not your fault. Nothing to be sorry about. As long as it works, I’m pretty much game for that. :)

    Comment Permalink

  • GravatarGinn Wei wrote from  Malaysia on October 18, 2007 at 00:44 and said:

    There’s a WordPress plugin that can do the same thing and much more. It’s called Who Sees Ads?. No, I’m not the plugin author or earning anything from this. I, myself, has just started to use it.

    Comment Permalink

Leave a Comment

You may use these tags in your comment:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Please take your time to read the comment policies for this blog especially if you're a new commenter.