We had a look at how you can automatically insert the ads in between your blog title and the blog content, now we will take a look at how you can insert the ads in between the blog posts on your blog front page.
Again you would have to do a simple change in your WordPress admin control panel by going into Design menu and choosing the Theme Editor. This time we will take a look at the Main Index Template, the index.php. Find the following line:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
You need to insert the following line above it:
<?php $count = 1; ?>
Now find the line that starts with following:
<?php the_content
After the closing tag of that section (?>) insert the following code:
<?php if ($count == 1) : ?>
YOUR GOOGLE ADSENSE CODE HERE
<?php endif; $count++; ?>
Now your blog ad will show in between the first and second blog posts on your blog front page. You can see this in action at HowtoMakeMyBlog.com.
Join thousands of bloggers and get all my blogging tips for FREE! Subscribe to HowToMakeMyBlog via RSS or via e-mail.
If you liked this article, you may also like:
Why I run my blog on Thesis Wordpress Theme
Thesis theme gives my blog a professional, clean, easy-to-read layout and SEO friendly design. Thesis makes it simple to make your own blog unique. See more details and get your own Thesis today.
{ 9 comments }
Brilliant!
I’ve been looking for this for a while. Thanks so much.
@Rahul, thanks a lot for your comment! I am glad that I could help!
thanks for the help, very useful info!
I cannot find the line which you provided in index.php
@Mohammed – It can be different from theme to theme so please check with your theme designer and the help files he has.
that line can be found in theloop.php
Hmm, still waiting for something to pop up. Stupid cache!
sooo, what if Id like to post, lets say a second ad underneath the third post as well?
@M, thanks for the comment! looks interesting, I will take a look at it.