If you are running a WordPress blog monetized with Google Adsense, you have probably looked for a way to hide Adsense ads from certain posts. You will be surprised how easily you can achieve this.
Google Adsense is a great program for publishers to monetize their blogs. It is a great way of funding your blog’s hosting costs and make atleast beer money from it. More serious folks make a killing with it and even try to replace their full time job.
There are a few things about Google Adsense that you need to be aware of to maximize its potential. You don’t want to turn off your regular readers by slapping ads everywhere. You want to target your ads to your search engine traffic.
You can easily address this like I have here using an excellent plugin called Who Sees Ad.
Who Sees Ad WordPress Plugin
This great plugin by Ozh is an advanced Adsense ad management plugin. It gives you great control over who can see your ads.
Who Sees Ads lets you create individual contexts for different ad units. For eg. I have a context which shows the main in-post Adsense ads only on posts older than 7 days. Usually most of my regular readers have already read the new posts and ads are shown primarily to Search Engine visitors.
Here is a screenshot of a setup I have
You can read all about this plugin here.
Why Exclude Ads from Certain Posts?
Let’s think about why you would want to do this first. Let’s say you had a post that was really popular with the search engines. But, the topic is in such an area that it is attracting really low CPC (cost per click) ads and very few clicks. You could improve your Click through ratio (CTR) by not showing ads on such posts. This would decrease ad impresssions on posts that hardly attract any clicks.
How do you Exclude Ads from Certain Posts?
With the Who Sees Ads plugin, excluding ads from certain posts of your choice is very easy.
- Find the ID of your posts you want to exclude from showing ads
- Go to the Edit posts section in WordPress admin
- Hover over the post and look at the status bar
- You will see the url as http://www.shankrila.com/wp-admin/post.php?action=edit&post=1297
- Here the post id is 1297
- Now go to the Who Sees Ads context you have (See screenshot for example)
- To exclude a single post from showing an ad, you’d add a condition like
is_single(‘<post_id>’) then don’t display
For eg. to exclude post id 1297 ,I’d add is_single(’1297′)
- To exclude a bunch of posts from showing this ad, you’d add a condition like
is_single(array(1297,1299, 1343, 1223)) then don’t display
- You can also use other WordPress conditional tags available here.
Even though I was using this plugin for a long time I never explored this conditional tag that lets you add any PHP code you find useful to narrow down to certain conditions.
I hope you enjoyed this little tutorial. As Matt noted, there wasn’t a source available that explained how to do this and I hope you found it useful.
Who Sees Ads has been a part of my collection of Top WordPress Plugins for a while now.