July 8, 2010

TEXT SIZE minus plus

How to Hide Advertisements for Single Posts

Advertisement
You Might Be Interested In Our Popular Article
  • Most Essential Free Softwares After Windows Installation
  • As in our previous tutorial, I showed you how to show your adsense to only Google visitors. In this tutorial you will learn how to hide advertisement for any particular post. This technique comes in handy if you publish many posts a day and want your regular readers not to get distracted by your ads, you can always show them up after a day is over or after a certain period of time.

    Step by Step Tutorial:

    Note: Do take backup of your theme before you try this.
    This example supposes that your ad codes are added in single.php file. You can edit different file if your ad codes are added in some other file.

    01. You need to know the ID of the Post on which you don’t want to display your ad. For determining it, you can check below link

    02. Go to Appearance => Editor.
    editor

    03. Then choose single.php file from right hand side and go where you have added your ad code and change it to:
    single.php
    From:

    …………

    Your Advertisement Code

    …………

    To:

    if(get_the_ID() != xx) {

    …………

    Your Advertisement Code

    …………

    }

    Replace xx with the post id for the post which you do not want to show advertisements for.

    03. You can also use this on multiple posts, just keep adding your Post ID’s in below pattern:

    if(get_the_ID() != xx || get_the_ID() != xx) {

    …………

    Your Advertisement Code

    …………

    }

    04. Save and you are done.

    Scripts Sources:

    That concludes this simple and useful tutorial. Hope you like it.



    Print

    About the Author

    When I was born I was so shocked I didn't speak for a year and half...... My brain has 2 parts, Right and Left, The Right one has nothing left in it and the Left one has nothing right in it......Who says Nothing is Impossible?? I've been doing nothing for years......
    • Pingback: designfloat.com

    • Pingback: wp-popular.com » Blog Archive » How to Hide Advertisements for Single Posts

    • http://www.shoutmeloud.com/ Harsh Agrawal

      This is really useful specially when you are writing posts for your affiliate pages… Shared on Twitter

    • http://www.smashinghub.com/ Ali Qayyum

      thanks for awesome hack

    • http://www.tutzone.org/ Bariski

      Glad you liked it. Thanks.

    • http://www.tutzone.org/ Bariski

      Happy to help. Thanks.

    • Ronald Bien

      I was looking for this kind of tut way back. thanks for this one bro :)

    • Pingback: Costa Rican Lawyers: How to find the right Costa Rica Lawyer | personal injury lawyers

    • http://twitter.com/mahasiswisexy mahasiswi sexy

      Thanks for Share….

    • http://pittsburghpersonalinjuryattorney.info/ pittsburgh injury attorney

      I think you’ve made some truly interesting points. Not too many people would actually think about this the way you just did. I’m really impressed that there so much about this subject that’s been uncovered and you did it so well, with so much class. Good one you, man! Really great stuff here.