WordPress.org

Ready to get started?Download WordPress

Forums

404's going to page.php (12 posts)

  1. cclass
    Member
    Posted 1 year ago #

    Hello,

    Although I have a 404.php file in my custom template directory, anytime a 404 is thrown, my site goes to page.php and displays nothing. The title of the page is 'Page Not Found' because it's trying to call the page title and my side bar (which should show the current page and any parent or sub pages) shows links to every single one of my pages.

    As a work around for now I have used the is_404 function to display an error which works just fine however I don't understand why the custom 404.php is not being called. I am using php include to show the content of the 404.php file.

    I've tried to follow WP troubleshooting with no luck

    perma link settings: /%year%/%monthnum%/%postname%/

    Not sure what other info would be useful for troubleshooting.

    Again, the page that you'll see if you try to go to a page that doesn't exist is the page.php file.

    Thanks!

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Although I have a 404.php file in my custom template directory

    Sorry? Custom template directory? That's not part of WordPress core. What theme are you using? Where did you download it from?

  3. cclass
    Member
    Posted 1 year ago #

    By custom template directory, I meant the directory where my custom theme is located (e.g. wp-content/themes/themename/404.php)

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    Ah! A child theme! What parent theme are you using? What happens if you switch back to the parent theme?

  5. cclass
    Member
    Posted 1 year ago #

    Hmm..I'm new to theme development so forgive my ignorance but I don't believe this is a child theme. The theme I'm developing is the only theme in that directory and (I don't think, at least not intentionally) does my theme inherit anything from another theme.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    So is this a custom theme? If not, where did you download it from?

  7. cclass
    Member
    Posted 1 year ago #

    Yes, it is a custom theme.

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    In that case, I would suggest that you start stripping back your theme's template files. It sounds like there's a problem in the way that they are using the Loop. Or perhaps you're running multiple Loops on a page - which can cause some really unpredictable behaviour unless they're implemented properly.

  9. cclass
    Member
    Posted 1 year ago #

    So I tried deleting all content from page.php and 404's still go to this page (indicated by a blank page...)

    How would issues with the loop affect 404's?

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    As I said, implementing the Loop incorrectly can cause some pretty strange behaviour. What happens if you switch to the default permalink structure?

  11. cclass
    Member
    Posted 1 year ago #

    I use this code anytime I start the loop:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    stuff
    
    <?php endwhile; endif; ?>

    More specifically this is used on index.php (the file where my posts are. I have a static home page), page.php, single.php and any custom page template.

  12. cclass
    Member
    Posted 1 year ago #

    Not sure if this is related, or just the default that I need to change, but when I view posts by month or year they show up using page.php as well.

    For example, if I went to http://site.com/2013/01 I would see all the posts for January but they would use page.php. I can fix this by using is_archive() but would prefer they go to another template.

Topic Closed

This topic has been closed to new replies.

About this Topic