Half-a**ed Adsense

May 18th, 2008. Tagged: WordPress

It's official, I switched to the dark side. Not only does this blog has ads but they are Google's adsense. But hey, you gotta try.

Because I was so hesitant and have been postponing this moment for years, I only did it half-way. I added a condition - only show ads when displaying a single blog post and if the post is older than 30 days. This way if you follow this blog regularly by RSS or any other way, you won't see ads when posts are published.

So here's the code in case it's useful for someone. The code is not a wordpress pluggin, I only modified the "Single page" template.

<?php
// 1/2-ass adsense
if (time() - strtotime($post->post_date) > 30 * 24 * 60 * 60) {
?>
  <div style="float: right; padding: 20px">
  <script type="text/javascript"><!--
    google_ad_client = "pub-8608773432853916";
    /* 250x250, created 5/18/08, first phpied test */
    google_ad_slot = "4896717118";
    google_ad_width = 250;
    google_ad_height = 250;
  //-->
  </script>
  <script type="text/javascript" 
   src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
  </div>
<?php
} // end adsense
?>

Basically it's the adsense-generated code wrapped in a div so I can float it and then wrapped in a condition that compares today's timestamp with the post's date.

Let's see what happens, maybe tomorrow I'll wake up rich. Or famous. Or both. :D

Tell your friends about this post: Facebook, Twitter, Google+

6 Responses

  1. That’s pretty lick, and so simple, even I didn’t think of that one lol. Hopefully Google doesn’t mind, although I don’t see why they should…

  2. Ya greedy bastard … Just joking ;) I like what you’ve done — putting your regular readers out of the “adsense experience”.

  3. [...] David Brooks wrote an interesting post today onHere’s a quick excerptNot only does this blog has ads but they are Google’s adsense. But hey, you gotta try. Because I was so hesitant and have been postponing this moment for years, I only did it half-way. I added a condition – only show ads … [...]

  4. [...] Go to the author’s original blog: Half-a**ed Adsense [...]

  5. I really enjoed this posting! Your sites looks great! If you are interested in anhy web design feedl free to contact me at http://vadoz.ru

  6. Thank you, I’ve just been looking for info approximately this subject for a long time and yours is the greatest I have discovered so far. However, what in regards to the conclusion? Are you certain concerning the supply?|What i don’t understood is in reality how you are not really much more neatly-preferred than you may be right now. You’re very intelligent.

Leave a Reply