1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How To Add AdSense To Almost Every WP Page ?

Discussion in 'Content Management' started by InFlames, May 15, 2008.

  1. #1
    Hi everyone,

    I started a WordPress blog and added AdSense to pages. I just edited the page.php page with the adsense code and its fine. But there are a few pages where I want no AdSense to be displayed.
    Is there a little piece of code to add so the AdSense code is excluded from these pages ?

    Thank you.
     
    InFlames, May 15, 2008 IP
  2. terminator69

    terminator69 Notable Member

    Messages:
    4,872
    Likes Received:
    260
    Best Answers:
    0
    Trophy Points:
    230
    #2
    What pages? separate posts?
     
    terminator69, May 15, 2008 IP
  3. InFlames

    InFlames Peon

    Messages:
    426
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Pages I write when you select write->pages, not posts. I have AdSense on all of them, by editing the page.php, there are just 2 or 3 that I don't want ads on.
     
    InFlames, May 15, 2008 IP
  4. Joomla Dude

    Joomla Dude Banned

    Messages:
    592
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You need to add adsense in
    singlepost.php
    pagetemplate.php
    index.php

    By this only,you can get the ads in all the pages.
     
    Joomla Dude, May 15, 2008 IP
  5. godsofchaos

    godsofchaos Peon

    Messages:
    2,595
    Likes Received:
    124
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Simply install Wordpress Adsense Manager plugin and its easy peasy!

    Cheers!
     
    godsofchaos, May 15, 2008 IP
  6. InFlames

    InFlames Peon

    Messages:
    426
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I already have AdSense on all the pages (pages only), there are just some pages I don't want ads on.

    I will try that,

    Thanks !
     
    InFlames, May 16, 2008 IP
  7. InFlames

    InFlames Peon

    Messages:
    426
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Well the plugin don't do what I want, so again I'll expose the problem, it is already written in the first post but it seems everyone give me solutions to add AdSense to every page. This is not what I ask.

    I have edited the page.php file so every page have AdSense ads on. But there are a few pages I'd like no ads on. So is there a way to "exclude" the code from these page, like some conditional tags or something ?

    Thanks.
     
    InFlames, May 16, 2008 IP
  8. Joomla Dude

    Joomla Dude Banned

    Messages:
    592
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Nopes,there is no way for it..
    You can only recode the template make it as a separate page and then exclude the ad codes from it.
     
    Joomla Dude, May 16, 2008 IP
  9. terminator69

    terminator69 Notable Member

    Messages:
    4,872
    Likes Received:
    260
    Best Answers:
    0
    Trophy Points:
    230
    #9
    Why would you want to remove ads from a few pages? I don't see your motif.
     
    terminator69, May 16, 2008 IP
  10. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #10
    By Pages do you mean Particular Posts.

    There is certainly ways to do this. It really depends on what you want. If you are talking about particular posts then you could use custom fields to do this easily, however I need more information on exactly what you are looking to remove the ads from (certain posts/404 pages/etc..)
     
    wd_2k6, May 16, 2008 IP
  11. terminator69

    terminator69 Notable Member

    Messages:
    4,872
    Likes Received:
    260
    Best Answers:
    0
    Trophy Points:
    230
    #11
    He wants to remove ads from certain pages. eg. you make 5 pages and only want 3 to show ads.
     
    terminator69, May 16, 2008 IP
  12. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Oh I see now well what you could do is something like the following:

    Wherever the Adsense code is placed inside the template you replace with the following:

    <?php if($hasadsense !== '') { ?>
    ADSENSE CODE HERE
    <?php } else { echo ''; } ?>


    OK Then on the sametemplate page where the Ad appears (e.g page.php) Find:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Replace this with:

    <?php if (have_posts()) : while (have_posts()) : the_post();
    $hasadsense = get_post_meta($post->ID, 'Adsense', $single = true); ?>

    OK after making these two changes resave the template file and re-upload it.

    Now hopefully, whenever you are writing a page that you want to show the AD on you would go to the Custom Fields Option, Type in a key of Adsense and a value of True.
     
    wd_2k6, May 16, 2008 IP
    terminator69 and InFlames like this.
  13. asbestos

    asbestos Active Member

    Messages:
    329
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #13
    in the theme choiose single post. or make it in footer. all will go auto
     
    asbestos, May 17, 2008 IP
  14. InFlames

    InFlames Peon

    Messages:
    426
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #14
    That works exactly how I wanted. Thanks a lot.

    For those who ask why I would want no ads on some pages, this is because they have other offers on them. AdSense could make them leave the page and miss these, while I have AdSense on page where there is only content.

    Thanks again wd_2k6. This thread can be closed now.
     
    InFlames, May 17, 2008 IP