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.

  • Google Buzz
  • Stumbleupon
  • Delicious

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
  • Make Money With Google Adsense Ads On Your Blog
  • How to get magazine style WordPress blog with Thesis Theme teasers
  • 8 Thesis theme design tips to make your blog better
  • Post written by Marko Saric on November 11, 2008 in Monetize your blog

    { 9 comments… read them below or add one }

    1 Rahul November 18, 2008 at 5:03 am

    Brilliant!

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

    Reply

    2 admin November 18, 2008 at 8:32 am

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

    Reply

    3 Bape Nerd April 9, 2009 at 8:27 am

    thanks for the help, very useful info!

    Reply

    4 Mohammed June 1, 2009 at 9:50 pm

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

    Reply

    5 Marko Saric June 2, 2009 at 2:39 pm

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

    Reply

    6 doug m July 1, 2009 at 4:34 pm

    that line can be found in theloop.php

    Reply

    7 Kevin March 13, 2010 at 3:11 pm

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

    Reply

    8 Kevin March 13, 2010 at 3:19 pm

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

    Reply

    9 admin November 17, 2008 at 3:29 am

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

    Reply

    Leave a Comment

    Previous post:

    Next post:

    Marko Saric on FacebookMarko Saric on TwitterMarko Saric on YouTubeHowToMakeMyBlog RSS