AdSense Between WordPress Post
Posted on October 2006 at about 10:50 pm by hwaFew days ago a friend of mine asked me how to insert Google AdSense in between posts in the main page, too bad that she is using Blogger and i'm not familiar with it.
Anyway this is how i do it in WordPress, it's very easy actually, all you have to do is to insert the following code into The Loop:
$gcount++; // google post counter
if ($gadv <3) { // how many ads to display?
if ($gcount%2 == 0) { // display ad after how many post?
$gadv++; // count number of adv
print 'Your Google AdSense Code Here';
}
}
?>
Don't forget to insert your own Google AdSense code, and you can put the above code anywhere in your "single.php" as long as it's in between the line:
and
Which is The Loop that i mentioned earlier.
You may want to change the parameter to suit your need, there are only two parameters you can set, first one is:
For the total number of AdSense display in your home page, remember that Google only allow a maximum number of three AdSense displayed in the same page.
The second parameter would be:
This one is to set your AdSense to display after the specific amount of post, the default setting is to display AdSense every two post.
Technorati Tags: Google AdSense, AdSense, Adsense Optimization, AdSense Tips, WordPress, WordPress Hacks, WordPress Theme, SEO








Leave a Reply