WordPress tutorials: Google ads after first post

Wpsnipp – This is an example of a loop that will use the loopcounter variable and include ad.php file after the first post. If you add your Google adsense code within the ads.php file or anything else it wil be displayed after the first post.

 

 

 

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); $loopcounter++; ?>
// the loop stuffs
<?php if ($loopcounter <= 1) { include (TEMPLATEPATH . '/ad.php'); } ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

Be Sociable, Share!

Leave a comment