Blog Tip: Comply With Google AdSense Restrictions On Your WordPress Index Page

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.)

Similar Posts:

32 Comments

  1. HMTKSteve says:

    I use the AdSense Deluxe plugin on all my blogs that use AdSense. I have never had a problem.

  2. Comedy Plus says:

    What did you say RT? I didn't get that, but when you talk this deep I never do. Just couldn't resist. :)

  3. Matt says:

    I've never had an issue with it. It's always just stopped displaying ads when it exceeds 3 ads. Not sure why, but I figured this was done on their part as it seems easy enough for them.

  4. goldcoaster says:

    I wondered why you could never get more than three ads in Blogspot – now I know.

  5. K-IntheHouse says:

    Great tip. As a recent Adsense user myself, I found out this little compliance aspect I wasn't aware of. I kind of did something similar in my theme code to control the number of ads to 3.

    Between you have given some nice links to intro articles that is now in my reading list.

    Thanks RT! :cool:

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

  7. Daniel Ted says:

    Great. What took you so long to tell us that? :lol: Thanks.

  8. Emad Ibrahim says:

    Thanks for this post… I found you through ProBlogger where my post on blogging tips
    made it to the list :)

  9. vijay says:

    Hmm great tip.. But will it work for all themes?

    Some days ago I was trying to put only one add unit on index page in post content. I did it through placing the adsense code in theme index.php page but it was showing three add units in three posts on index page.

    I will try this code to see if I can restrict it to one.

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

  11. Edward Dowd says:

    I didn't know google adsense restricted to 3 ad units. weird.

  12. GnomeyNewt says:

    I am experimenting with the skylock plugin to delay ads, so far it has worked great. This tip would still work well for those that want to keep things simple and not use yet another plugin!

  13. HMTKSteve says:

    I'm switching one of my sites over to adbrite and this code made the page not render at all.

  14. Dan says:

    I've been searching high and low for a method to do exactly this. I didn't like the big gaps the empty ads left, and this is a simple way to remove them.

    Dan's last blog post..Review

  15. Rob says:

    Hey Great info . I gather some very informative bloggin adsense :mrgreen:

    Rob's last blog post..G Lock Blog Finder

  16. To solve this problem I personally use Semiologic – I think Denis Bernardy did a great job in his latest version of WordPress based solution, because the ad management got super easy – simple drag and drop.

    I was afraid that in case you edit the one post template (in Semiologic) it will put AdSenses at the top of each post, so that on the index page of my blog I would have 10 adsense blocks.

    No! It worked around it. So, guys and gals, my advice is to also use Semiologic to comply with AdSense policy on blogs.

  17. I wrote some code myself to use on blog but yours has an option to mention where to display ads and where not. Good work buddy.!

    Flashy Flashy's last blog post..Post title, archive page title optimization in blogger (blogspot subdomains)

  18. Adsense Land says:

    That saved me from a major headache. Thanks.

  19. Joe says:

    SAVED ME A BUNCH OF TIME!!! CHEERS

  20. Noman says:

    Good article about google AdSense. This helped me a lot to understand Google AdSense. I found another site about AdSense certpaper dot com.

Leave a Reply

CommentLuv Enabled

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

Anti-Spam Protection by WP-SpamFree