How To: Remove Ads from Categories

by Yan

It’s been said that monetization should be done in moderation without appearing too obtrusive to your readers.

One of the most common approaches is to insert ad banner or adsense within the post. In-line ads are perceived to have one of the highest click-through-rate (CTR).

Now what if you do not want to show ads on posts within certain categories? In some instances, what if you want to remove ads on all your sponsored reviews?

WordPress Hack

In my search to find the possibility to do so, I’ve just discovered a nice little hack that removes any ad from any category.

I’m not too sure if this function is going to serve any real purpose to you but in the spirit of sharing, I’m going to show you how to do it in WordPress.




Insert your ad banner or adsense code here


In the above code 15 and 23 are category IDs, replace them with the IDs of the categories you don’t want ads in.

If you are clueless, here’s how to check your category ID

I am currently using this code to remove private ad from my Review categories. Probably by doing so, I’m giving the maximum exposure to the advertisers who ordered my review.

Source: JohnTP

post scriptum

Since php and me don’t seem to go along well most of the times, I’m asking anyone here if it is possible use if/else statement within the code.

What I’m trying to do here is to show adsense on one particular category and private ad on the other.

update:

John from The Mobility Tiger – a site that talks about health and mobility issue – has shared with us a simple php hack and here’s the code for the if/else statements.




        Insert your ad banner here

    

         Insert your adsense code here

    

        Insert your ad banner or adsense code here


All you need to do is to change the word ‘false’ to whatever you want to test for. In this case the category ID.

A big thanks to John for sharing.

Related posts

{ 28 comments… read them below or add one }

Tiger November 7, 2008 at 7:08 pm

Sorry about the formatting, I tried to make it readable, but you could do something like the below, using ‘else’ and ‘elseif.’

Just change false to whatever you want to test, in this case the in_category test.

Right now it would print the last else statement, because both of the tests are false.

AdSense Code 1

AdSense Code 2

AdSense Code 3

Tiger´s lastest post..Scuba Diving for the Mobility Challenged

Reply

Tiger November 7, 2008 at 10:12 pm

So that comment originally had a php snippet in it, but I guess wordpress doesn’t like putting that in a comment. If it doesn’t show up let me know, I can email it or something, but basically else and elseif is what you were looking for…

Reply

Yan November 8, 2008 at 4:24 am

Ooops! The demon is eating up the code again. Anyway, I’ve just emailed you….hope it doesn’t goes into spam….

Thanks for your input and glad to take time to visit.

Yan

Reply

jbj November 7, 2008 at 7:42 pm

Nice post, Yan! I have a made a few similar posts on WpRecipes.

jbj´s lastest post..How to: create an ads rotator with php

Reply

Yan November 8, 2008 at 4:36 am

My bad! How could I forget that you are the master of WordPress hacks…;) Let’s see what Tiger has got to say, if there is none I’ll probably jump over to your forum for the code.

Thanks for dropping by…

Yan

Reply

Alex Fraiser November 7, 2008 at 10:13 pm

Ah if only I had discovered this trick when I had my last blog. Oh well. But this is going to be useful for me later down the line, bookmarked.

Alex Fraiser´s lastest post..When you think a website is down…

Reply

Yan November 8, 2008 at 4:25 am

So what happen, Alex? You sold your last blog?

Yan

Reply

Alex Fraiser November 9, 2008 at 6:50 am

Yes, I sold it. I have a new blog in the works, so I will be sure to use this trick on it.

Alex Fraiser´s lastest post..Finding the source of an argument…

Reply

newbiesblogger November 7, 2008 at 11:04 pm

nice, maybe I will use this post as my reference when my blog already have ads on it.. Nice

newbiesblogger´s lastest post..My Blog Is Suckzzz!!!

Reply

MoneyBlog November 7, 2008 at 11:44 pm
Ganesh November 7, 2008 at 11:59 pm

Looking at code makes me feel lost. Is there any plugin that allows us to specify on which categories the ads should appear and on which they should not?

Ganesh´s lastest post..Commenting My Way to Success!

Reply

Yan November 8, 2008 at 4:33 am

Tell me if you found one, Ganesh and share it with us here. Probably there is but I’m yet to find one…

Yan

Reply

Lyndi November 8, 2008 at 3:01 am

I saw this one on the reader and I thought ‘here is one I know the answer to.’ When I opened the site I found that Tiger had beat me to the punch – shucks!

Lyndi´s lastest post..Blog Review: http://www.Rarst.net

Reply

Yan November 8, 2008 at 4:30 am

Thanks for dropping by, Lyndi. You seems to know your stuff well, huh? I wouldn’t mind if you share with us here..

Yan

Reply

Unique Blogger November 8, 2008 at 3:37 am

Yan! This wordpress hack is awesome.

“I am currently using this code to remove private ad from my Review categories. Probably by doing so, I’m giving the maximum exposure to the advertisers who ordered my review.”

Well done!
Best Regards

Unique Blogger´s lastest post..Twitter, Promote Your Blog or Website

Reply

Yan November 8, 2008 at 4:32 am

@Unique Blogger

Glad you like it. By the way, I wish I knew your ‘unique’ name, buddy….if you don’t mind…

Reply

Unique Blogger November 8, 2008 at 6:15 pm

:D In next your post i will sing my name bellow comment :D

Unique Blogger´s lastest post..Twitter, Promote Your Blog or Website

Reply

Ben "the frog" Tremblay November 8, 2008 at 4:28 am

Thanks for sharing this and also thanks to tiger/Lyndi for another way of doing it with the in_category.

I don’t see why I would use it right now as I don’t run in-line ads I want to remove for specific categories, but I keep the article in mind if I ever need to do it.

Thanks for sharing yan!

Ben “the frog” Tremblay´s lastest post..Offline marketing: I see huge potential

Reply

Farrhad November 8, 2008 at 3:24 pm

Nice one Yan!
Thanks for shring it with us. I will implement it on my blog :)

Farrhad´s lastest post..Things You Must Do Before You Turn 40

Reply

Web Talk November 9, 2008 at 1:19 am

Great Hack! I didnt even know that adsense has a strong CTR when it is inline. Anyway I dont want to put ads in the middle of an article. I think it is too invasive and can be perceived as a “moneymaker” for the webmaster. What i do instead is to put ads at the beginning and at the end of my post. to do it i just use a code that i put in the theme’s loop (no plugin). Your hack is really nice anyway. I am going to speak about it!

Web Talk´s lastest post..Download a video editor, photo/video converter for free

Reply

Dennis Edell November 9, 2008 at 8:12 am

Awesome little hack buddy…although I’d probably have to have someone else do it for me. ;)

Dennis Edell´s lastest post..Are You Able To Focus & Take Action? A 5-Step Plan That WORKS.

Reply

Yan November 10, 2008 at 2:21 pm

Hey Dennis,

Let me know whenever you need an assistance. I’ll always be there…

Yan

Reply

Ange November 12, 2008 at 8:40 pm

I hope this code will be usfeful for removing the ads from review categories.

Reply

Rajesh November 12, 2008 at 9:18 pm

A very handy trick for beginners. Though there are several plugins for adsense that can easily do this.

Reply

Diana Rupert November 13, 2008 at 7:03 pm

Thanks! It was really a great tip for a beginner like me. Thanks for the trick

Diana Rupert´s lastest post..7 Secret Tips to Rapidly Lose Weight

Reply

MR.Nan November 14, 2008 at 10:09 am

Thank you so much ! Yan I think it was really good tip for me and everybody. God bless you.

MR.Nan´s lastest post..Mycapitalonecard.com

Reply

IronBlogger - Blogging Tips and Tricks November 24, 2008 at 9:34 am

I have never done this nor did I never know how to do it. I looks pretty easy enough though. Thanks for the tip.

I do have to mention though that by getting rid of your advertisers are you making it up for them? I mean after all they do pay to advertise on your blog? Unless of course you are only removing AdSense then it’s no prob. Just wondering from an advertisers perspective.

Thanks for the little tutorial Yan.

IronBlogger – Blogging Tips and Tricks´s lastest post..Create A Pop Up Form With Aweber

Reply

Craigslist Chicago August 14, 2009 at 3:09 pm

yes inserting code with in the text cause high ctr, however use good and matching color scheme to full fill your users reading interest

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: It’s Time for Readers’ Appreciation #2

Next post: How I Increase My Email Subscribers by 60 in 7 Days