0

I made a basic site based off the underscores (_s) theme with a CPT/taxonomy, Advanced Custom Fields plugin, and 3 page templates. A simple site. Nothing out of the ordinary.

For some strange reason, when "pretty" permalinks are enabled, all pages and pagination links redirect to the 404 template. When I remove the 404.php template, the index.php is displayed in defiance of WordPresses template hierarchy (I have page.php, etc)

  • The site works correctly with "ugly" default permalinks
  • This happens on both local MAMP and remote Cpanel hosting
  • Ive re-generated the .htaccess file many, many times
  • CPT name/slug is not conflicting with page url names / persists if I remove CPT
  • Theme file/folder permissions are correct
  • Switching to default 2024 theme causes permalinks to work correctly (ruling out server config)
  • Issue persists with all plugins disabled and theme files stripped down to the very basics (ruling out plugins)
  • WP/plugin versions are all up to date.
  • Renaming theme did nothing
  • No errors in logs
  • Searched high and low on forums, tried everything I could possibly think of.

Ive been developing WordPress for well over a decade and havent ever run into this and it's making me loose my marbles!

...what in a theme would even be affecting permalinks?!

Any help greatly appreciated!

2 Answers 2

0

Do the old urls still work after enabling "pretty" permalinks? Only your cpt and taxonomies for it don't work but the rest of the site does?

Flush Rewrite Rules: WordPress uses rewrite rules to handle permalinks. Sometimes, these rules do not recognize new custom post types or taxonomies until they are flushed. You can flush the rewrite rules by going to Settings > Permalinks and simply clicking "Save Changes" without altering anything. This often resolves permalink issues with custom post types.

You can also try to create another custom post type and taxonomy while the pretty links are enabled to see if it works. Use a basic naming convention to make sure it is not something related to that.

If that works then you know it is something to do with the names you are using.

2
  • The CPT pretty urls actually work with pretty permalinks, its the pages (with and without custom templates) that dont. Ive flushed rewrite rules many times to no avail.
    – user239138
    Jan 8 at 21:28
  • If you explain to me how exactly how to reproduce the error on my site, if I can reproduce the error I can fix possibly, if it works on mine then maybe it is something on your system. Jan 8 at 22:05
0

After many frustrating hours debugging. I have a solution for anyone who finds themselves in this predicament:

It was because I had a blank '/' slug under one of my CPT registration rewrites:

'rewrite' => array('slug' => '/','with_front' => false),

In order for permalinks to work correctly, this must have a slug set and then rewrite rules need to be flushed, making it particularly hard to debug.

Phew - Hope this helps someone!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.