I have registered a custom taxonomy on "post" named "cat_modules" with this args:

'rewrite' => array(
        'hierarchical' => true, 
        'slug' => '/',
        'with_front' => false

I used 'hierarchical' => true to have the url structure like 'category/subcateogry' and I used 'slug' => '/' to remove the "cat_modules" from the slug.

These work well on the archive pages but all posts and pages return a 404 error. If I remove 'slug' => '/' from the args everything work well.

P.S In this web site is installed WPML.

  • 1
    You need something to distinguish it from pages. Otherwise category/subcateogry just looks like a page called subcategory that's a sub-page of category. Jan 12, 2019 at 13:45
  • @JacobPeattie Thank you for your answer! I wasn't thinking about it!! now I understand why also the home page works!! Do you know some tricks or best pratices for do that? I forgot to write that I would like also have this URL structure to post like category\subcategory\post-title.
    – S Madry
    Jan 12, 2019 at 14:09

1 Answer 1


OK, so you've used / as you taxonomy slug. It means that URL for your term is:


And for pages it will be:


As you can see, there is no way to guess, what type of post should WP search for.

WordPress processes the URLs looping through registered Rewrite Rules and matching given URL against regular expression assigned to current rule.

That means that in your case WP will take first rule that will match correctly and try to display that type of object. And because there are two different objects registering rules that are in conflict, then you'll get 404 errors for some of them.

  • Thank you Krzysiek for your explanation!! Now I understand the issue. How could I workaround this problem? Maybe I could explode the slug for "/" and check if the first result is a terms and handle the response.
    – S Madry
    Jan 12, 2019 at 14:48
  • You can use parse_request action and add you custom parsing code in there. But it’s always a little bit risky. Jan 12, 2019 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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