Add content after First Post

sticky-adYou might want to add Google Ad after your first post on the home page. But when you put your adsense code inside the loop, you will see that your ad will be displayed throughout the page after each post and if you put your ad code just after the loop your ad will be displayed at the very bottom of the page.

Here is the forum to put an add after the first post

<?php if (have_posts()) : while (have_posts()) :
the_post(); $postcounter++; ?>
// your loop
<?php if ($postcounter <= 1) { // you advertisement code here } ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

Pretty simple! Wasn’t it ? Adding an icing to cake just you change the $postcounter <= 1 to $postcounter <= 2 the if you want advertisement to be displayed both after first and second post.

Related posts:

  1. How to Insert content after each post in WordPress
  2. How to create a WordPress Theme
  3. How to Create Post Accordions in WordPress
  4. How to Create a WordPress Plugin – Hello World!
  5. WordPress Plugin – RSS Post Editor


The author is a small business owner himself specialising in Web Development. He runs Insight Studios which offers specialized Web Development, SEO Services and PPC Management for Small Business and SME thus ensuring growth and prosperity using the power of social media.

Share This Post

Related Articles

Leave a Reply

© 2012 MyGeekPal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Designed by Insight Studios