January 10, 2006

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?

Bookmark at:
    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at del.icio.us    Digg WordPress 2.0 problems for google adsense users, and a workaround at Digg.com    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at Spurl.net    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at Simpy.com    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at NewsVine    Blink this WordPress 2.0 problems for google adsense users, and a workaround at blinklist.com    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at Furl.net    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at reddit.com    Fark WordPress 2.0 problems for google adsense users, and a workaround at Fark.com    Bookmark WordPress 2.0 problems for google adsense users, and a workaround at YahooMyWeb
Filed under , , , , , by Emily from How to Blog.
Permalink • Print •  • Comment

Related posts

    Track this entry:

    Trackback url

    Cosmos

    Terms2tags:

    Comments

    January 10, 2006

    Matt said:

    I’ve been using live preview on my account for around 6 months (I think) and my adsense or YPN hasn’t been deactivated. My earnings have only gone up too. I don’t think it’s worth getting so excited over a theoretical problem. If someone actually affected, then make an issue of it.

    Also, as I told Michael on IRC, another easy workaround for this is to check if the current user is the admin, and not show the ad then.

    January 11, 2006

    Emily from How to Blog said:

    Hi Matt,

    Thanks so much for responding to my post (I’m genuinely honored that you’re even reading any part of my blog :)

    I’m thrilled to hear that there is another workaround for the adsense/live preview issue. Since Michael didn’t post it, and for those of us who aren’t as familiar with the code behind the scenes, could you kindly provide an exact codeblock for how one would encorporate the workaround that checks if the current user is the admin in which case the ad would not be shown? This way I can not only encorporate it on my own WP 2.0 blogs and report back on the experience, but I can also show my blog readers how to apply the workaround, as well. If the code differs dependant upon whether it is in the loop or not, can you provide both code examples? I would greatly appreciate it.

    Thrilled to hear your earnings have only gone up — that’s great news! I hope the same holds true for me once I start doing more WP 2.0 blogging.

    And to address the making a stink about the issue prior to knowing anyone whose account actually was deactivated - I think it is somewhat warranted in that some people rely on their adsense revenue to get by (if not as a sole source of income for them) and once your account is revoked, there’s no going back — so to wait until Google notices that you’re breaking their TOS and deactivates your account is a scary proposition. I hope you can see where I’m coming from on that.

    Looking forward to hearing back from you.

    Matt Read said:

    here are some ways to overcome the is_preview flackyness:

    Check the post status:

    global $posts;
    if ($posts`[0]->post_status != “draft”) {
    … do ads here …
    }

    Or, similar to what Matt said, check if the user is author. (You don’t need to see your own ads anyway).

    global $posts, $current_user;
    if ($posts[0]`->post_author != $current_user->ID) {
    … do ads here …
    }

    January 19, 2006

    Marcia said:

    Thanks, this is gret information for those of us who are using Wordpress 2.0. Do you mind telling me exactly WHERE in the template I would need to paste the above code that checks if the user is the author?

    Thans=ks again!

    January 20, 2006

    Lucky7Star said:

    Ok, I admit I’ve been into Word Press just about long enough to have broken my share of templates. Is this a true issue or something like while standing on your head on Tuesday kind of upside down and backwards you might trip the wrong attribute in your MySQL table that reverses the polarity of the universe and causes a 400 page lighting bolt to strike from the skys of the Google editors whom perish your account from this world and the next. Look, maybe this is a silly assumption but I figure the editors over at Google are aware of this problem and will not banish you from the world of the living on account of some accident of missplaced code… But just in case I’m wrong I’ve install 2.0 on one account and kept 1.5 on the other. In the event the worse case scenario plays out and one should suddenly find themself banished to the underworld of Yahell, or assimilated by the undead of the Bill Gatius Borg, I’m not going to miss a few Adsense dollars… It might even motivate me into landing a real job… If anyone has a flashlight and a map out of this black hole hotel California:)

    January 31, 2006

    Mr Blogmeister said:

    I don’t believe this is a problem. Question, are there any adsense ads placed on a 404 page. Answer No. I agree that the google bot gets a 404 error, but the bot finds no ads to serve. No ads, no violation. Simple as that

    Larry

    Leave a comment

    Made with WordPress and the Semiologic CMS | Customized by Emily Robbins