Support » Fixing WordPress » WordPress 404.php file is never called

  • Hi,

    I’ve been testing my site to make sure everything is in working order, and come to find out, it’s not (big surprise…) Whenever someone tries to go to a non existent page, they get the standard “problem loading page” error, instead of the WordPress 404 page.

    The site is on my local machine for now, or I’d give a link.

    I’m pretty sure the problem is that WordPress doesn’t know that the user is getting a 404. At one point I had this string of code in my index.php file:

    <?php if (get_page_name() == ‘home’) {
    include ‘home_content.php’;
    } elseif (get_page_name() != ‘home’) {
    include ‘subpage_content.php’;
    /*the above is still in my index.php file, below is all that has been changed.*/
    } elseif (is_404()) {
    include ‘404.php’;

    Any help is appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi


    Forum Moderator

    Do you have a 404.php file in your theme? If so, you could try removing:

    elseif (is_404()) {
    include '404.php';

    I do have a 404.php file. I suppose I should have made myself a little bit more clear. I added the elseif (is_404()) because WP wasn’t handling errors on its own, so I thought that would help (which wasn’t quite brilliant, seeing as I used a wp function) That’s why I think wp doesn’t realize the page is 404ing

    Thanks for the response! I tried removing the elseif, and still got the “file not found” error. Any more ideas?

    Does anyone have any idea why this isn’t working?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress 404.php file is never called’ is closed to new replies.