groups

info


tags: Wordpress

Link to this snippet:


Download to Code Collector

language: PHP
licence: Other

Display Google Ad after the first post

options: send to code collectorview all maeghan's snippets


/*A lot of people have asked me for this. How to display a Google ad after the first post? It is very simple. You just need to add a variable ($loopcounter) in The Loop. If the $loopcounter is less than or equal to 1, then include google-ad.php code.*/


<?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; ?>