Add adsense in your WordPress blog

After writing a comment on, I was “due” to post it here. I managed doing the same though using a different method. Yes, it’s possible to do something similar using other way. But mine is, I would say, easier to manage. I got the wonderful Acme tech Adsense Deluxe plugin which allows me to plug the ad into the script easily. My code is only added at 3 different places in the templates files: 1. In the theloop.php, find
then add this code just before
< ?php if ($adsensevar == 2){ adsense_deluxe_ads('Midpage'); $adsensevar = 0; }else{ $adsensevar++; } ?>
This code will output a ad every 3 posts (but beware, google TOS says no more than 3 ads per page, so I’ve warned you). 2. In the sidebar.php just before the div class clear, add
< ?php adsense_deluxe_ads('Sidebar'); ?>
This code output the ad in the sidebar 3. In single post add
< ?php adsense_deluxe_ads('Midpage'); ?>
after the
< ?php include (TEMPLATEPATH . '/theloop.php'); ?>
call. This will output the ad just before the comments and the comment box. Using ad sense deluxe (which you should have actived), create a block called MidPage (which would generally contain the code for a 468×60 banner) and a Sidebar (which contains any scrapper kind) and you’re done. Might be a bit long, but it’s easier to manage after. Ask any question if there’s a problem.
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Yahoo! Buzz

12 Responses to “Add adsense in your WordPress blog”

Comments are currently closed.