Placing Adsense Between Posts - Wordpress

The placement of ads within a blog can have a dramatic effect of the success of your ads. This is particularly true when you talk about Google's Adsense. I'm not going to praise one ad type or the best placement in this post. What I am going to do is show you how to easily place ads (or some other content) between posts.

Personally I have had success placing an ad block between the 1st and the 2nd Post. I will show you how this can easily be achieved with Wordpress.


With Wordpress this can easily be achieved by modifying the template and adding some additional code within the loop.

Just a brief explanation - the Loop processes each of the posts to be displayed on the current page and formats them accordingly.

The basic loop looks like the following, but will be certain to have addition a code in place for various reasons:

<?php if (have_posts()) : ?>
  <?php while (have_posts()) : the_post(); ?>   
  <!-- do stuff -->
  <?php endwhile; ?>
<?php endif; ?>

The following will easily allow you add an ad block between the 1st and 2nd post:

= 1; // set counter to 1 for ads
if (have_posts()) : ?>

  <?php while (have_posts()) : $postcounter = $postcounter + 1;                             

the_post(); ?>
  <!-- do stuff -->
  <?php if(2 == $postcounter)  {
  <div id="adsbetween">
  <-- Place ad code here -->
;  }  ?>

  <?php endwhile; ?>
<?php endif; ?>

How it Works?
What we have done is added a variable called $postcounter and assigned it a value of 1. Each pass of the loop increases the value of $postcounter by 1. To vary where the ads appear simply change the value numerical value in the line:

<?php if(2 == $postcounter)

adsense between posts

Excellent, the only coding I have found that worked with my theme without upsetting the layout, thanks!

Submitted by Joe (not verified) on Mon, 2011-05-09 05:23.

Adsense is really one of the

Adsense is really one of the best way to make some bucks, I have across many famous blog owners and they are arguing that Adsense is one of the best way to make some money online and that too for a long period of time. Placing adds in between post can increase their click through rate. Thanks for share.

Submitted by William Smith (not verified) on Sun, 2011-06-19 19:04.

Website Development

In my blogging career first time I had found some code is working exactly. Otherwise some or other changes have to be done to run the code.

Submitted by Software Application Development (not verified) on Sat, 2012-03-31 23:31.