How to not displays Adsense in certain post

dont display google ads How to not displays Adsense in certain post

This is kinda weird post. Since everyone would like to show their adsense ads in their post, you also want to know how to not displays the adsense ads in your post right? There’s some situations where we don’t want to show our google ads in the post such as for the paid post right? Here’s the simple trick to do that.

I know there’s a Adsense Plugin that can do this simply such as the Shylock Adsense Plugin. But not everyone like to install a lot of plug-ins to their post and they just simply love to mess their hand with the codes. So, here’s the simply solution on “How to not display Google Adsense in your post”.

First, open up your theme files. And then, search for your adsense code that you have embed before in your single.php theme file. And the, wrap a div tag to the adsense code so it will be look like this:


<div id="nogoogleads">
Paste your google adsense ads in here.
Copy and paste the whole codes here.
</div>

After that, save the single.php file. To not shown the adsense ads in some of your post, add this code in Write editor HTML mode anywhere in it:


<style>#nogoogleads {display:none !important;}</style>

And then, publish you post and you can see that your Google Adsense ads wouldn’t be displayed in the post. Simple trick for anyone that don’t want to displays their adsense ads in some of their post. There’s also a php codes to do this. But you need to add your post id to the php strings everytime you want the ads not to be displayed. Not everyone like to do that right?

By using this technique, you also can use it to only show certain type of adsense ads box. Just paste 3 type of adsense block into your single.php file by wrapping them in 3 different div tag. For example:


<div id="myads1">
Paste your first google adsense block codes here
</div>

<div id="myads2">
Paste your second google adsense block codes here
</div>

<div id="myads3">
Paste your third google adsense block codes here
</div>

And then, just substitute the div tad id of the adsense code that you don’t want to displayed into the css style below. For example, you just want to show the myads1 adsense ads only in your post. Paste the following codes to the bottom of the post:


<style>
#myads2{ display:none !important}
#myads3{ display:none !important}
</style>

Always and always remember to paste that codes in HTML mode in your WYSIWYG post editor. In wordpress, it look like this:
not displays adsense edit How to not displays Adsense in certain post

This is the power of CSS codes! Haha

Comments

  1. The Net of Inter

    Did you do this yourself? I’m impressed. well done. even though i know coding for the most part i have a thing for plugins and option screens….but great post. i’m enjoying the design of your site too.

  2. syuxx

    Yeah, it just a bunch of css & html codes.
    nothing cool in it. haha

  3. titan

    hoho..thats good. But i just prefer with normal way.

  4. [...] to ThumLog for their great post on this great [...]

  5. [...] to ThumLog for their great post on this great [...]

  6. [...] to ThumLog for their great post on this great [...]

  7. [...] and manually added a flag that will disable the ads on a per-post basis using a tip that I found here. Thanks Internet [...]

Leave a Reply