This post has been updated to fix a couple of errors.

The top Search Engine Optimization (SEO) sites recommend placing an ad after the first post on your blogs home page. This is quite effective as the visitor is less likely to get ad blindness and ignore the ad.

This is very easy to do and shouldn’t take more than 10 – 15 minutes to implement. I’ll be showing how to insert the code in an Artisteer theme but the technique will work for any theme that uses the standard WordPress Loop.

The first thing to do is make a backup of your index.php file just to be safe.

You want to locate this bit of code…

<?php if (have_posts()) : ?>

And insert this directly above it…

<?php $count = 1; ?>

The above code will start our counter to determine which post we’re on. Next find this bit of code…


<?php endwhile; ?>

And insert the next chunk of code between the div and the endwhile statement…

<?php if ($count == 1) : ?>
<div class="adblock">
==> Insert your Google AdSense code here <==
<?php endif; ?>
<?php $count++; ?>

This will insert the ad code if the counter ($count) equals ’1′. If you want the ad to appear after the second post just change the number to ’2′. You’ll notice we also added a new CSS class so that we can position and style our adblock to fit our theme. Below is the CSS you might use to center a 468×60 adblock…

.adblock  {
margin-left:84px;/* depends on your content width */

That’s it. Try it out and start monetizing you blog.

If you have any questions or need some help, just leave a comment and I’ll do what I can to help you out.


I make no promises as to the functionality of these modifications to your theme code. Do it at your own risk. Do it on a backup copy. Do it while wide awake and after having plenty of sleep or plenty to drink, your choice. Don’t do it to your original code. Don’t do it while sleepy, cranking, or driving. And most important, don’t expect it to work the first time. If it does work the first time you probably got lucky. Besides, if you don’t break things you never figure out how they work. And last but not least…Have fun and learn something new.

Awesome Themes

Genesis Framework for WordPress

Favorite Random Quotes

“You can't wait for inspiration. You have to go after it with a club.”

by Jack London