How to exclude Adsense code from certain Posts?

Discussion in 'WordPress' started by Jalpari, Oct 25, 2010.

  1. #1
    Is there a little piece of code, I can exclude ADSENSE ads from appearing on certain Posts?
     
    Jalpari, Oct 25, 2010 IP
  2. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #2
    You can't if the codes are in your theme files.
     
    Abhik, Oct 25, 2010 IP
  3. dynashox

    dynashox Premium Member Staff

    Messages:
    8,662
    Likes Received:
    563
    Best Answers:
    3
    Trophy Points:
    335
    #3
    dynashox, Oct 25, 2010 IP
  4. dmohan

    dmohan Active Member

    Messages:
    415
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    73
    #4
    search for "adsense themes" you will get it. New one is heat map theme.
     
    dmohan, Oct 25, 2010 IP
  5. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #5
    use php code like this...
    if (!is_category()) {

    /* Adsense code */

    }


    similarly you can use is_single, is_page() so that the adsense will only show up on category or single post pages. You can also target specific posts, consult wordpress codex
     
    olddocks, Oct 25, 2010 IP
  6. alexsc29

    alexsc29 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Great idea, I'll try, thank you
     
    alexsc29, Oct 25, 2010 IP
  7. Jalpari

    Jalpari Notable Member

    Messages:
    5,640
    Likes Received:
    137
    Best Answers:
    0
    Trophy Points:
    260
    #7
    Suppose i want not to show ads on post no 2,7,9 then how i will write code and where i will place this code ( in the loop ?)

    Thanks i already search google for this link but want a piece of code for theme.
     
    Jalpari, Oct 26, 2010 IP
  8. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #8
    Its easy

    if (!is_single(2,7,9)) {

    /* Adsense code */

    }


    dont forget that you have to open your theme folder and make changes to single.php
    Here is your reference: http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
     
    olddocks, Oct 26, 2010 IP