Adsense on Blogs

Discussion in 'WordPress' started by CaffinePhil, Mar 3, 2008.

  1. #1
    Hello.

    I have a new blog with a sidebar that I seem to only be able to add widgets/plugins to. Is there any way I can get Adsense to appear in this sidebar?
     
    CaffinePhil, Mar 3, 2008 IP
  2. pushkar26

    pushkar26 Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    quite simple, open sidebar.php in an editor and add your adsense code. Make sure you respect the .css restrictions. This would allow your ads to come in a better fashion.

    Also you can generate ads based on the background theme of your sidebar, would look good
     
    pushkar26, Mar 3, 2008 IP
  3. CaffinePhil

    CaffinePhil Banned

    Messages:
    945
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks pushkar26,

    I'll give that a go. How would I add the adsense to individual posts?
     
    CaffinePhil, Mar 3, 2008 IP
  4. mizaks

    mizaks Well-Known Member

    Messages:
    2,066
    Likes Received:
    126
    Best Answers:
    0
    Trophy Points:
    135
    #4
    mizaks, Mar 3, 2008 IP
  5. pushkar26

    pushkar26 Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    You can do lots of experiments, however this example i've carried from somewhere else. But works


    If you want the ad at the bottom of your posts:
    But what if you wanted an ad to only appear under the first post and nowhere else ?

    Open your theme index.php, and find this line:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    Immediately above that, paste this:
    Staying in index.php, scroll down to this part:
    You put ALL your code, plus the bit at either end, into the gap I pointed at.
    The 'value' is where to show the post. The bottom part checks to see what the number is and when the number matches, it puts the ad on the screen. So if you made $showadsense1 = 3; in both locations, the ad would appear only after the 3rd ad.


    Want 1 ad after the first post and 2 after the second ?
    Copying from above, you would use this instead:
    which would go at the top.

    Again copying from the above, you already have this:
    The first bit says the values, then the values are checked each time WP goes through The Loop.
    If the counter matches what your value is, the ad is shown. Changing the numbers lets you change the placement.
     
    pushkar26, Mar 3, 2008 IP