4
votes

I have the following setup:

  1. A custom post-type “intern_post” with slug => 'intern/post'
  2. A custom taxonomy “intern_category” with slug => 'intern/category' which is linked to the CPT
  3. The taxonomy registration runs before the custom post type registration

The error (404) occurs when I’m trying to access the custom taxonomy archive pages from 2 and on.

First I thought WordPress might get confused with the custom taxonomy and post-type. But the error still occurs even if I register the custom taxonomy with a simpler and unique slug…

The Query Monitor Plugin even indicates that WP recognizes the right rewrite rule(s):

intern/category/([^/]+)/page/?([0-9]{1,})/?$ => intern_category=$matches[1]
&paged=$matches[2]

I’ve seen some similar problems where they tried to solve the issue with tons of additional rewrite rules—which in my eyes seemed pretty dirty.

To me it seems like the rewrite rules themselves work, WP get’s all the necessary Query parameters set but still refuses to load the correct template file.

Does anyone have a clue what’s wrong here?

1
Have you updated the permalink from Setting=>Permalink? - Mohammad Ashique Ali
Can we see the actual URL to which you are getting the error? (e.g. example.com/intern/category/ .... ) - Jamie_D
@MohammadAshiqueAli yes, of course I did. - cruzquer
@Jamie_D E.g. example.com/intern/category/term/page/2. example.com/intern/category/term/ itself works perfectly fine. - cruzquer
Most likely a trivial and obvious question, but are you flushing the rewrite rules database after making any rewrite changes? (i.e. Select Settings -> Permalinks and just click Save Changes without any changes) - Jamie_D

1 Answers

0
votes

You cannot use a slash in the slug. See Slug Formatting : Acceptable Characters.

I also wouldn’t use dashes, but underscores instead. It used to cause problems, though it might work with recent versions of WordPress.