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.



    Related Posts From Network
    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......

    View Comments to “How to Hide Advertisements for Single Posts”

    Author comments are in a darker gray color for you to easily identify the posts author in the comments

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

    2. Ali Qayyum says:

      thanks for awesome hack

    3. Bariski says:

      Glad you liked it. Thanks.

    4. Bariski says:

      Happy to help. Thanks.

    5. Ronald Bien says:

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

    Comments are closed.

    blog comments powered by Disqus