Insert Ads In Between Blog Posts On Your Main Page

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:

  • Insert Ads In Between Title And Content Of Your Blog Post
  • The Simplest Way Of Increasing Your Blog Page Views
  • How to automatically add Tweet This to your blog articles
  • How to get magazine style WordPress blog with Thesis Theme teasers
  • 8 Thesis theme design tips to make your blog better
  • Why I run my blog on Thesis Wordpress Theme

    WordPress Thesis 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.

    Post written by Marko Saric on November 11, 2008 in Monetize your blog

    { 9 comments }

    Rahul November 18, 2008

    Brilliant!

    I’ve been looking for this for a while. Thanks so much.

    admin November 18, 2008

    @Rahul, thanks a lot for your comment! I am glad that I could help!

    Bape Nerd April 9, 2009

    thanks for the help, very useful info!

    Mohammed June 1, 2009

    I cannot find the line which you provided in index.php

    Marko Saric June 2, 2009

    @Mohammed – It can be different from theme to theme so please check with your theme designer and the help files he has.

    doug m July 1, 2009

    that line can be found in theloop.php

    Kevin March 13, 2010

    Hmm, still waiting for something to pop up. Stupid cache!

    Kevin March 13, 2010

    sooo, what if Id like to post, lets say a second ad underneath the third post as well?

    admin November 17, 2008

    @M, thanks for the comment! looks interesting, I will take a look at it.

    Previous post:

    Next post:

    Search Enginedata recovery