22 Mar 2007

Add !is_preview() Around Advertlets / Nuffnang Code

For ‘s or Nuffnang‘s WordPress publishers, it’s important for you to add !is_preview() conditional tags around their given JavaScript code. This will prevent the advertisements code from initializing and appearing while you’re editing / managing your entries from Post Preview section in the Administration Panel (even Google prevents this sort of behavior in Google Adsense program).

Also, it would be smart to add !is_user_logged_in() too. There’s no point of making the code appear on your own blog while you’re logged in (unless you’re debugging your CSS or layout).

For example:

if ( !is_user_logged_in() && !is_preview() ) {
        JavaScript code goes here..
}

At the time I’m writing this, there’s still no WordPress plugins either for Advertlets or Nuffnang yet to be found. Hint! Hint!