Half-a**ed Adsense

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

This entry was posted on Sunday, May 18th, 2008 and is filed under WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

5 Responses to “Half-a**ed Adsense”

  1. BillyG Says:

    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. Harry Munroe Says:

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

  3. Half-a**ed Adsense Says:

    [...] 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. Half-a**ed Adsense Says:

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

  5. Yeteri Says:

    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

Leave a Reply