WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to remove adsense on a certain wordpress page (18 posts)

  1. raymondcc
    Member
    Posted 8 years ago #

    How can I remove adsense on a certain page on wordpress?
    If I insert the code at the Presentation -> Theme Editor -> Main Template, all of the pages will display adsense.

    If anyone has solution, please do share. Thanks.

  2. Kafkaesqui

    Posted 8 years ago #

    When you say 'page' do you mean Page (as in Write > Write Page), or just generally?

    In either case, check the information on conditional tags, which will be beneficial to you here:

    http://codex.wordpress.org/Conditional_Tags

  3. raymondcc
    Member
    Posted 8 years ago #

    Sorry, as in Write > Write Post

  4. Kafkaesqui

    Posted 8 years ago #

    http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page

    Example:

    <?php if( !is_single() ) : ?>
    ~ your ad code goes here ~
    <?php endif; ?>

  5. raymondcc
    Member
    Posted 8 years ago #

    <?php if( !is_single(Beef Stew) ) : ?>
    ~ your ad code goes here ~
    <?php endif; ?>

    Correct me if I am wrong...
    If I use the code above, if the title is Beef Stew, it will display the ad code.

    What I want is I want to remove the ad code which is embeded at every post on a certain post I select.

  6. ladydelaluna
    Member
    Posted 8 years ago #

    I'm not sure how, if you've set your template to post an ad on every single post, how to have it NOT do that on one particular post - the only way I'd think would be to use the adsense plugin and include the ad tags on posts you WANT to have google ads, as opposed to the ones you don't.

    the ad tags are as simple as <!--adsense--> so it's not like you'd have to grab the whole adsense code every time...

    check it out here: http://www.acmetech.com/blog/adsense-deluxe/

    i hope that helps you out... let us know?

  7. raymondcc
    Member
    Posted 8 years ago #

    I am actually using Adsense Deluxe to manage my google ads.

    Actually the ads that I don't want to show on a post is from another company called ExpoActive. At the beginning of this topic I mentioned google ads is because everyone knows what adsense is for easy understanding.

    I've already set my own template to show the ads on every single post and there's one particular post that I don't want to have any ads at all.

    So I was wondering how can I do that?

    Do you think whether it's possible to change the "post" to "page" to have better control? The post currently has a lot of comments already.

  8. ladydelaluna
    Member
    Posted 8 years ago #

    Okay, now i'm confused.

    This is NOT a google ad that you're wanting to remove? But you said it was in the beginning of the thread because you thought it'd be easier to understand? Kind of silly if you ask me, because now, very little of the time spent giving you advice on this was worth it.

    If I'm mistaken in that, my apologies, but I can't understand why you'd say they were adsense ads and now say they're not?

    If it IS adsense, then isn't there a way to exclude a certain URL from showing up in your ads from within adsense when you get the code?

    If it's not adsense, then maybe you need to contact the ad company...

    I don't believe you can change a post to a page without just creating the page, but then you'd lose the comments.

    I'm just confused by your request at this point... how can we help you if we don't know what kind of ads you're running?

  9. Kafkaesqui

    Posted 8 years ago #

    If it's just one post you do not want to display *any* ad on, then this should work:

    <?php if( !is_single('Beef Stew') ) : ?>
    ~ your ad code goes here ~
    <?php endif; ?>

    Note the quotes around post title for the is_single() argument. You can also pass the post ID instead of the title if you have problems with the former method.

  10. ladydelaluna
    Member
    Posted 8 years ago #

    Kaf - that code says "your ad code goes here" which would lead one to believe that the code you gave is FOR posting an ad, on just one post. Not for REMOVING what he's already got defaulted to show up for just one post.

  11. Kafkaesqui

    Posted 8 years ago #

    Note the if statement's evaluation:

    !is_single('Beef Stew')

    The ! in PHP parlance means 'not' (for those who didn't know), so in effect it's saying:

    If we are *not* on a single post page with the title 'Beef Stew' do the following

  12. ladydelaluna
    Member
    Posted 8 years ago #

    ahhh ok.
    well i guess that's a lesson to ya... we're not all PHP people around here, ya know! ;)

    seriously - i had no idea about the ! and it's meaning in PHP, and apparently neither did raymondcc... this explanation would've helped us understand that before.

    but thanks for the code, Kaf - you never fail us around here!

  13. raymondcc
    Member
    Posted 8 years ago #

    ladydelaluna, actually the ads that I don't want to show on a post is from another company called ExpoActive.

    Oh my I am confused too. So will the code work in my case?

  14. Kafkaesqui

    Posted 8 years ago #

    Your original question:

    "How can I remove adsense on a certain page on wordpress?"

    Which I believe has since been clarified down to: "How do I display some ad code everywhere on my blog but for one specific post?"

    If this is correct, the conditional code example provided above will do that.

  15. raymondcc
    Member
    Posted 8 years ago #

    Sorry for my english.

    I believe "How do I display some ad code everywhere on my blog BUT for one specific post?" is my question.

    I will try to use the code suggested.

    Should I insert the code in the Post?

  16. Kafkaesqui

    Posted 8 years ago #

    Again from your first post:

    "If I insert the code at the Presentation -> Theme Editor -> Main Template, all of the pages will display adsense."

    Follow the same steps, but slip my if statement around the code.

  17. raymondcc
    Member
    Posted 8 years ago #

    Oh it worked!
    Thanks a lot and so sorry for all the confusion.

  18. Malaiac
    Member
    Posted 8 years ago #

    Using metas would have done the same
    if (meta is set) then (do not display) else (display).
    It would have allowed you to make others posts without "expoactive" ads. EDIT : and without to have to get back to code every time.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.