Problems with wordpress 404 page not showing

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.

Tags:

2 Responses to “Problems with wordpress 404 page not showing”

  1. Ramon says:

    Thx for posting this!. I was getting crazy trying to find out this same issue.

  2. TERRY says:


    CheapTabletsOnline.Com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. High quality drugs. Order drugs online

    Buy:Viagra Super Active+.Maxaman.Super Active ED Pack.Levitra.Cialis Professional.Tramadol.Viagra Professional.Viagra Super Force.Soma.Viagra Soft Tabs.Viagra.Cialis.Cialis Super Active+.Propecia.Cialis Soft Tabs.Zithromax.VPXL….

Leave a Reply