WordPress.org

Ready to get started?Download WordPress

Forums

WordPress 404.php file is never called (4 posts)

  1. NNDT
    Member
    Posted 4 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 4 years ago #

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

    elseif (is_404()) {
    include '404.php';
    }
  3. NNDT
    Member
    Posted 4 years ago #

    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?

  4. NNDT
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.