groups

name language licence
Untitled Snippet PHP Other
Unique Category template PHP Other
Display Google Ad after the first post PHP Other
Custom Fields PHP Other
Dynamic Content Dynamic Content PHP Other
Unique Single template PHP Other
Query Posts PHP Other
Feature post highlighting PHP Other

< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 >



language: PHP
licence: Other

Display Google Ad after the first post

options: view full snippetsend to code collector


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

	
(Continues...)