Don't forget to subscribe to my RSS feed!

Semi-coherent ramblings of an internet junkie about business, life & gaming.

How to place Google Adsense after your first post

A friend of mine asked me if I knew how to place the Google Adsense code in a Wordpress blog, right after the first post. So I figured, why not make a topic about it.

So here goes:

Placing an ad right after the first post is very effective. This is because the ad is integrated in the blog content, hence visitors are less likely to develop “ad blindness” and skip over the ad.

To place an ad after the first post in your WordPress blog main page:

  1. Open the WordPress admin control panel and navigate to:
    Presentation > Theme Editor
     
  2. Select the Main Index Template from the list of templates on the right.
     
  3. In the Main Index Template, find the line that starts with:
    <?php if (have_posts())
     
  4. Add the following line above it:
    <?php $count = 1; ?>
     
  5. Next, find the line that starts with:
    <?php the_content
     
  6. After the closing tag ?> for that section (it may wrap to multiple lines), add the following code:<?php if ($count == 1) : ?>
    – Insert your Google AdSense code here –
    <?php endif; $count++; ?>
  7. Click Update File.

This places the ad within the first post.  If instead you want the ad to appear between the first and second post, add the code from step 6 after the closing </div> tag for the “entry” div that contains the line <?php the_content.

comments

Leave a Reply




*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture.
Anti-spam equation

  • Featured content

    On occasion I try and do some special stuff. For instance I do usability tests on websites. Or you can take a look at some of the famous interviews I've done.

  • Stefson in a nutshell (long)

    Stefson.com has grown out of my previous site www.mmopiglet.com (which no longer exists), that was mainly about my time in mmo games. Ever since I stopped playing mmo’s, due to personal reasons (read: time), I missed blogging so much, that the decision to start over from scratch on a new domain was easily made. So here we are.

    I blog mostly about web2.0, technology, book reviews, Wordpress themes and plugins, tools for web savvys, usability, websites, gaming.

  • Text Area #3

    This is an area on your website where you can add text. This will serve as an informative location on your website, where you can talk about your site.