| name | language | licence |
|---|---|---|
| Adding a Mini-Loop | PHP | Other |
| Untitled Snippet | PHP | Other |
| translations of CSS3 selectors for SocialMe | PHP | Other |
| Template Tags/wp list bookmarks | 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 |
< 1 2 3 >
language: PHP
licence: Other
Display Google Ad after the first post
options: view full snippet • send 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; ?>



library
buttons (3)
wp (93)