How to Blog: Your Comprehensive Source for WordPress Themes, Plugins, Tips, Tricks, Reviews and News

Subscribe to our newsletter for the latest WordPress tips!

WordPress 2.0 problems for google adsense users, and a workaround

As just another reason to not upgrade to WordPress 2.0 (or even install it in the first place for now), it’s been widely reported that WP 2.0’s live preview feature causes serious problems for those bloggers who utilize Google’s Adsense to monetize their blogs.

Lunacy Unleashed has a great article on dealing with the adsense problems in WordPress 2.0 dealing with the adsense problems in WordPress 2.0, as well as a few workarounds.

In sum, the problem stems from the fact that the live preview will try to fetch your google adsense ads, even if your post has not yet been published. This can be seriously problematic, as when google tries to determine appropriate contextually relevant ads for the page, it receives a 404 (page not found) error because the page does not yet exist. At a minimum, this could result in ads that aren’t relevant to the content on your page. At it’s worst, it could result in your adsense account being suspended, “since Google prohibits displaying ads on 404 pages”.

Not good.

Michael Hampton’s post provides details on how to get around this problem by modifying your template code (which beginning WP users are probably not so comfortable doing..) to put in a check to see if the what’s being displayed is a preview, and if so not display AdSense ads using the following code:

// Paste your AdSense code here //

Unfortunately, this workaround still results in multiple problems, the first one being that there is a known bug with the is_preview() function in WP 2.0. Furthermore, the abovementioned code only works ‘inside the loop’ (see Matt Read’s post for help in understanding “the loop”, as well as the information on The Loop in the wordpress codex)

Michael suggests yet another workaround for those who want to place their ads outside the loop (a common occurence) in the form of the following code:

is_preview): ?>
// Paste your AdSense code here //

HOWEVER, because of the problems with the is_preview function being quirky in WP 2.0, these workarounds don’t always work and in the words of EUGENIUS, “It looks like until is_preview is fixed, don’t put adsense on the WordPress (2.0) blog.”

To me, I find this unbelievably unacceptable -with the given propensity for the majority of bloggers these days to utilize Google AdSense ads on their blogs, I simply cannot understand how it is possible that this was not resolved prior to WordPress 2.0’s being released, and is reason alone not to use it (never mind upgrade your existing installations to WP 2!) And shouldn’t there be a simple checkbox to just turn live preview off for those of us who would rather have AdSense ads working on our site than see a live preview of our post?? How hard would that really be?

Click Here to Leave a Comment Below

Leave a Reply:

Pin It on Pinterest

Share This