WP AdSense

Discussion in 'AdSense' started by calum, Nov 20, 2007.

  1. #1
    Hello.

    I am having trouble adding AdSense ads to wordpress.

    My blog is at www.calumneilson.com/blog

    I was wondering how it would be possible for me to add adsense below the first post at www.calumneilson.com/blog but above the second, if you know what I mean.

    I also want to know how to add adsense to below posts in the viewing a single post page (eg. http://www.calumneilson.com/blog/2007/11/10-tips-for-choosing-your-domain-name/)

    I want it to be around where the social bookmark icons are for the second bit.

    Thanks
    Calum
     
    calum, Nov 20, 2007 IP
  2. yinshang

    yinshang Peon

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here’s a simple way to put an AdSense ad after the first post in your WordPress blog (on the main page, not on an individual post page).

    Go into the WordPress control panel > Presentation > Theme Editor

    Choose Main Index Template on the right

    Find the line that starts with:

    <?php if (have_posts())

    Create a new line above it and add:

    <?php $count = 1; ?>

    Then find the line that starts with:

    <?php the_content

    Create a new line below its closing tag (the line may wrap so the closing tag may be on the next line down!) and add:

    <?php if ($count == 1) : ?>
    Your Google AdSense code
    <?php endif; $count++; ?>

    Hit Update File, and you’re set. If you wanted to make it after the 2nd post, change “count == 1″ to “count == 2″.

    This places it inside the actual post, right at the end. If you want it outside the post, find the closing </div> tag for the “entry” div and place the last piece of code we added after that.
     
    yinshang, Nov 20, 2007 IP
    Ibn Juferi and calum like this.
  3. yinshang

    yinshang Peon

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
  4. calum

    calum Peon

    Messages:
    2,821
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks yinshang, greatly appreciated and works great, +rep :D
     
    calum, Nov 20, 2007 IP
  5. ForgottenCreature

    ForgottenCreature Notable Member

    Messages:
    7,473
    Likes Received:
    173
    Best Answers:
    0
    Trophy Points:
    260
    #5
    ForgottenCreature, Nov 20, 2007 IP
  6. logeshnkl

    logeshnkl Well-Known Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #6
    My suggestion is use Mighty Adsense plugin for Wordpress. It will be very simple and easy to use though..
     
    logeshnkl, Nov 20, 2007 IP