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.

StumbleuponDelicious

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

    { 1 trackback }

    shane glass
    October 27, 2009 at 5:03 am

    { 8 comments… read them below or add one }

    1 Make Money Blog November 14, 2008 at 4:16 pm

    Thanks for the great sharing!
    Between, there is an awesome plugin named “Adsense Injection” and did the great job for injecting your adsense within your blog post. I forgot the link, you can simply google it. Hope it helps. :)

    Reply

    2 admin November 17, 2008 at 3:29 am

    @Make Money Blog, thanks for the comment! The link is http://www.biggnuts.com/adsense-plugin/ , looks interesting, I will take a look at it.

    Reply

    3 Rahul November 18, 2008 at 5:03 am

    Brilliant!

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

    Reply

    4 admin November 18, 2008 at 8:32 am

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

    Reply

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

    thanks for the help, very useful info!

    Reply

    6 Mohammed June 1, 2009 at 9:50 pm

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

    Reply

    7 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

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

    that line can be found in theloop.php

    Reply

    Leave a Comment

    Previous post:

    Next post:

    Marko Saric on FacebookMarko Saric on TwitterMarko Saric on YouTubeHowToMakeMyBlog RSS