Archive for September, 2009

Disable google translate

Friday, September 25th, 2009

Got a problem with dodgy users from obscure countries causing havoc on your website? I recently noticed a huge number of people using Google translate to access a website. If you want to prevent people using Google translate on your website you can use.

<meta name=”google” value=”notranslate” />

In your HTML page inside the head section. Users don’t seem to get an error message from Google, it just gives them a blank screen instead of their translated page.

Problems with wordpress 404 page not showing

Friday, September 11th, 2009

I recently had an issue with the 404 page not displaying in Wordpress. I Googled heavily and couldnt find the solution to my problem. The issue was causing a blank page to appear (the theme itself appeared but not the text in 404.php) – there were no visible errors. I was pretty certain there was nothing wrong with my theme, mainly due to the fact that there were no PHP errors showing and get_404_template() returned the correct location of my 404.php file.

After reading this post on the wordpress support forums I wondered if it might be a server setting. Looking further into the is_404 function I discovered that was being set by the set_404 function which was being called in wp-includes/classes.php from handle_404. This was where I found my issue. Inside handle_404 you find the following line


<?
if ( (== count($wp_query->posts)) && !is_404() && !is_search() && ( 
$this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === 
strpos($_SERVER['REQUEST_URI'], ?))) ) ) { 
?>

Which checks the $_SERVER['QUERY_STRING'] – for some reason this wasn’t being set on my server for reasons that I’m still not 100% clear about. Anyway, removing the $_SERVER['QUERY_STRING'] from the if statement solved the problem for the mean time and my 404 pages now work like a charm. I’m currently still trying to work out whats causing QUERY_STRING to become unset – i’ll let you know when I’ve worked it out.