Turn Off Google Ads in WordPress If Admin
December 2nd, 2008Tags: adsense, google, PHP, WordPress
Categories: Programming, WordPress
You’ve implemented Google Adsense in your WordPress blog. Now, you want to avoid accidentally clicking on an ad to avoid being penalized by Google.
If you’ve manually added Google Adsense to your WordPress theme, this article is for you. If you are using one of many Google Adsense Widgets, this article might be for you assuming you know how to modify an existing widget.
This article will give you an idea on how to add a simple PHP code in your template to suppress Google Ads if a user or an admin is logged in to WordPress.
We will use the “is_user_logged_in()” function to determine if a user or an admin is logged in to WordPress. A simple “if” statement is employed to display or not display the ad.
Sample 1 – The format:
...
Place your Google Adsense code here ....
...
Sample 2 – With actual Google Adsense Code:
Place this code to every Google Adsense code in your template. To view the ads, simply logout of WordPress.
Hi, Ive got a couple of questions about your wordpress template that I started using (awesome) is it possible to talk directly I sen my email…Thanks
Don,
I’m not exactly sure what you meant. Can you rephrase your question?
VRy interesting to read it