Display Google Ad after the first post
August 7, 2008 · 483 Views · Filed Under WordPress
I don’t use Adsense on this blog, but I do use it on other sites of mine. I can’t remember where I found this, but I did save the code and instructions.
1. Create a file named “google-ad.php” containing your Adsense code.
2. Upload the file in the directory with your other template files.
3. Open your home.php template file and change it to the following code:
View Code PHP
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); $loopcounter++; ?> <?php if ($loopcounter <= 1) { include (TEMPLATEPATH . '/google-ad.php'); } ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?> |
If the $loopcounter is less than or equal to 1, then it includes your google-ad.php which contains your Adsense code.
Comments
Leave a Reply






Become one of our 
