How to add AdSense after first post on WordPress

Adding an advertisement like Google AdSense after the first post is a good idea for those who look for making money from advertisements, there are many plugins which will do this job, but its not feasible to implement plugins for every needs on site.

Here is an example of WordPress loop which will allow you to insert advertisement like Google AdSense, custom ads after the first post. It use a variable to count the number of post and when it attain the particular count will display the ad. You can insert your ads ‘in your_ad.php’.

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

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …


Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us