Index.php Causing 404 for Custom Post Types

2 Replies ·

  1. Justin,

    First off, congrats on the redesign! Can’t wait to see how the new forum plugin develops.

    A few weeks ago, I was looking at your Ravel theme, and I really liked the way you just used the `index.php` template file. I’ve since switched my themes over to this structure.

    However, I keep getting support requests about Custom Post Types returning 404 errors now. I’ve had users switch to a previous version with the all the old template files, and this solved the issue. The issue can also be solved be re-saving the Permalink structure.

    What I don’t understand is how this new structure is causing these issues? Have you had the same problem with Ravel?

    Thanks for you time!

  2. Justin Tadlock

    A 404 error is generated by WordPress before templates are handled. I pretty much want to say that it’s outright impossible for your template structure to do anything like this, but I hate to rule out anything completely. I just can’t think of a possible reason this would have anything to do with templates.

    I’m also assuming you’re not doing anything crazy like putting CPTs into your theme. I could see a theme update being a cause for this if that were the case.

    Going to the “Settings > Permalinks” page (don’t have to save) flushes the rewrite rules for WordPress. There are factors that come into play on occasion where people simply need to flush their rewrite rules to straighten things out.

    I also use this structure with many themes (including the one on this site). No issues with CPTs and 404s. Can you link to a theme where you’re having problems? I’ve got plenty of CPTs set up on my install and can at least test this.

  3. bens

    Justin,

    That’s very helpful, thank you.

    Here’s the theme I’m having the issue with: https://wordpress.org/themes/tracks

    I’m going to check out the code differences again and see what else I can find because it sounds like the template files aren’t causing the issue after all.