Welcome IP: 209.234.171.36

Adding AdSense ads between WordPress posts

Send this article to a friend Send this article to a friend

In the following tutorial, I explain how to place Google AdSense ads between your WordPress posts. This is similar to the option of placing adsense ads on posts in category results pages tutorial with the exception that this example places ads on your Blog's Main index or Home page.

How to Add Ads Between Posts:

1. Log into your WordPress admin panel
2. Select Presentation -> Theme Editor from the navigation menu
3. From the Theme Editor, find and select the "Main index template" (index.php) from the list to the right
4. Find the following line

PHP:
  1. <?php if (have_posts()) : ?>

5. Above it add the following line

PHP:
  1. <?php $count = 1; ?>

6. Now find the following line

PHP:
  1. <div class="entry">

7. Add the following code directly below it (replace AdSense Code with your code)

PHP:
  1. <?php if ($count == 1) : ?>
  2. AdSense Code
  3. <?php endif; $count++; ?>

8. Click update file, then go view your site to confirm that the ad has been added to the first post listing.Note: To change which post your ad is placed under, simply change the count numberExample: $count == 2 will place the ad under post 2


                            

If you find this information useful, feel free to express your support via a quick PayPal Donation: