There are a lot of customizations available, if you are using Google Adsense to monetize your blog and using WordPress as the blogging platform. You can use plugins to show or prevent Adsense ads anywhere in your blog posts, but if you need to prevent Adsense Ads on selected posts or pages, here is a quick tutorial.
Let’s say you write a weekly round up post where you do not want to show any the ads but would want the ads to appear in all other posts. This can be achieved using WordPress custom fields and a simple conditional check as described below:
Prevent Adsense Ads on Selected Posts using Custom Fields
1. Open the corresponding file of your Wordepress theme where you have the code of your Adsense unit. This can be your single.php file for single posts, index.php for home page or may be sidebar.php for the sidebar.
2. Paste the following code where you would want the ads to appear or hide:
if ($ads_display == “no”){ ?>
<!– no ads –>
<?php } else { ?>
Enter ad unit code
<?php } ?>
3. Replace “Enter ad unit code” with the actual code of your Adsense unit, save the file and upload it back to your themes folder.
4. Log in to WordPress administration area and create a new post. Assign a custom field with the name as “ads” and choose the value as Yes or No.
5. If you choose “Yes” the ads will appear as usual while choosing No will hide the Adsense ad on that selected post.
Note: All the earlier posts will display the ad units as usual but you can still use the custom field on older posts and hide or show the ads.
This method is good for hiding ads in selected posts or pages but it has one disadvantage. You have to choose the custom field for each and every post and set the value to Yes or no. To solve this, you can use a category and prevent the ads from appearing in all posts of that category.
Hide Adsense Ads on Posts of A Particular Category
This method is simple, just create a category and whenever you want to hide the ads on a particular post – assign the post this category. Here are the steps:
Open the corresponding file of your WordPress theme and paste the following code wherever you want the ads to appear
<!– no ads –>
<?php } else { ?>
Enter ad unit code
<?php } ?>
Remember to replace “categoryid with the actual ID of the caegory. Multiple categories work out just fine.
More tweaks:
1. Show Adsense ads on longer posts using word count.
2. Show Adsense ads only to Search engine visitors.




Pingback: stryker hip replacement recall
Pingback: Ons Kookboek is en blijft dé kookbijbel van Vlaanderen ! Standaard Boekhandel 2013 , Lekker koken en genieten van makkelijke en heerlijke keukenrecepten uit 3.000 kookboeken plus originele, gezonde recepten uit ons eigen online kookboek.
Pingback: read here
Pingback: Photovoltaik l Heiszsysteme l Solaranlagen l Sanierung Heizung l Solarenergie
Pingback: vegas hotel promotions
Pingback: LSAT test prep
Pingback: upholstery cleaning okotoks
Pingback: Agriturismo in Toscana
Pingback: http://carautoinsuranceratesquotes.com/
Pingback: plumer jacksonville florida, plumbers jacksonville florida, plumbing jacksonville florida, water heater jacksonville florida, water heaters jacksonville florida
Pingback: เอเชีย
Pingback: ofis kırtasiye
Pingback: Fleshlight Kopen
Pingback: Web Site
Pingback: Norman
Pingback: เกม
Pingback: car locksmith
Pingback: collants
Pingback: justcloud pricing