Google's "AdSense for Content" policies restrict every page on your blog to three ad units, three link units, three referral units and two search boxes (see Google AdSense Program Policies). Many of you place at least one ad unit in the content section of each article. On the index page (the home page) it's a good idea to place a single ad on three individual articles instead of multiple ads on one article.
How do you comply with the restrictions if you're displaying more than three articles on your index page? The answer lies in editing the theme. Yes, there are plugins that will insert your code into specific places in your theme. At least one of them purports to limit the ad units to three on the index page, but I never tested it to find out. Editing the relevant part of the theme is easy. You only need to concern yourself with the index.php file. The instructions that follow are the way I control my ad placements on the index page.
You start by placing your AdSense code where you want it to display, the best place being between the post title and the content. Once you have it in place, insert this code just before the beginning "<script" line:
<?php
$gcount++; // google post counter
if ($gadv < 3) { // how many ads to display?
if ($gcount%1 == 0) { // display ad after how many posts?
$gadv++; // count number of advertisements
print '
Then after the "</script>" of the final line of the code:
';
}
}
?>
After you get it set up properly, it doesn't matter if you display three or ten articles on the index page. Only the first three will only have ad units on them. If you need help with your theme, feel free to send me a message via my contact page.
This is not the only way to control ad placement on the index page. I recommend you read Darren Rowse's article, "Introduction to Advertising Optimization - Ad Position", and Aaron Brazelle's article, "How to: Placing Adsense Strategically Between Posts".
Thanks to Matthew of eJabs for sending me the code a few months ago.
(Update 2007-08-11: I now use the Shylock Adsense Plugin to do the dirty work for me. I made one change to the plugin to make it work with certain kinds of posts but other than that, it does the job.)




[...] Blog Tip: Comply With Google AdSense Restrictions On Your WordPress Index Page by RT Cunningham [...]
[...] Blog Tip: Comply With Google AdSense Restrictions On Your WordPress Index Page by RT Cunningham [...]