If you look at Sabahan.com main page, you’ll notice that I’ve placed the Adsense rectangle ad after the 3rd, 6th, and 9th posts. BTW, I might change this setup in the future.

The way I do this is by editing the following block of code in my index.php file.

Yours may be a little different from mine but it should resemble either this:

<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>

Some code here…

<?php endforeach; else: ?>

Or this

<?php while (have_posts()) : the_post(); ?>

Some code here…

<?php endwhile; ?>

This is where wordpress loop through and display your post one by one as long as there are posts to display. What I’ve done is to add a counter to count if a particular post is the 3rd, 6th, 9th, 12th and so on. If that condition is true, then my Adsense code will be placed at the end of that post. So, for the first code snippet example above, add <?php $counter = 0; ?> before

<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>

Then add the following code to display your Adsense code after the 3rd , 6th , 9th etc. posts only.

<?php if(++$counter % 3 == 0) { Echo “Your Adsense code here”; } ?>

It must be added before the end of this code:

<?php endforeach; else: ?>

Your final code should look like this. For the first code snippet

<?php $counter = 0; ?>

<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>

Some code here…

<?php if(++$counter % 3 == 0) { Echo “Your Adsense code here”; } ?>

<?php endforeach; else: ?>

And if your index.php code resembles the second code snippet, your final code should look like this:

<?php $counter = 0; ?>

<?php while (have_posts()) : the_post(); ?>

Some code here…

<?php if(++$counter % 3 == 0) { Echo “Your Adsense code here”; } ?>

<?php endwhile; ?>

To change the ad intervals between your posts, just change the number ‘3′ above to a different number. If you want to display one ad only after the 2nd , 3rd , 4th etc and not have it repeated, you can refer to the original tips at ProBlogger on how this is done.

My advice is not to go overboard, plastering your blog with ads all over thinking to make more money at the expense of your readers’ experience. In such case, what’s more likely to happen is you’ll annoy them, and risk losing your regular or potential readers.