Support » Fixing WordPress » 404 error problem

  • Hello–

    I just noticed that I’m having quite a bit of trouble with 404 error pages on my WP site. I do not have a 404 template, and I do not have any 404 directives setup. This generates an internal server error for invalid URLs ending in .php–just what I’d expect–but on invalid URLs to directories, havoc breaks loose: I get a ton of errors on the page, these two repeated over and over:

    Invalid argument supplied for foreach() in /var/www/html/wp-includes/template-functions-category.php
    on line 395


    Warning: in_array(): Wrong datatype for second argument in /var/www/html/wp-includes/template-functions-category.php on line 399

    I think I know what’s causing these errors. In header.php, I’m using a number of conditional statements to display certain header images depending on the category or page you’re on, stuff like:

    if ( !is_home() && in_category('54') ) {
    echo "<img src="images/header/header_1.gif" alt="" width="335" height="90" border="0" />"; }


    elseif ( !is_home() && (in_category('55') || in_category('56')) ) {
    echo "<img src="images/header/header_2.gif" alt="" width="335" height="90" border="0" />"; }


    else {
    echo "<img src="images/header/header_default.jpg" alt="" width="335" height="90" border="0" />"; }

    In this case with the problematic 404s, I think the last statement above is being ignored. What I’m trying to say there is “if the page is ANYTHING else other than what has been specified above, display header_default.jpg”, and my intention is for the 404 pages to fit into this and display the default graphic. Instead, the header’s conditional statements results in WP looking for in_category and this is where it gets all funky.

    Any ideas? Is there a way that I can use a conditional statement to check if the user is on a 404 page (ie. if error=404 echo thisimage)?

    All comments appreciated!!

    JF 😉

  • The topic ‘404 error problem’ is closed to new replies.