I've created a CPT named "decoration products"(productos decoración), the problem concerns to it CPT.

When for the first time I created "decoration products" CPT, I realized that it needed two level taxonomy uri structure. To visually illustrate it:

  • Root_domain/CPT name/ - This is a page that shows all "decoration products" CPT's posts.

  • Root_domain/CPT name/category - This is an archive page that shows top level category's posts.

  • Root_domain/CPT name/category/subcategory - This is an archive page that shows subcategory's posts.

  • Root_domain/CPT name/category/subcategory/post-title - This is a post within a certain top category and subcategory.

I based on this post:

  • wordpress.stackexchange.com/questions/39500/how-to-create-a-permalink-structure-with-custom-taxonomies-and-custom-post-types

to create two level taxonomy uri structure for "decoration products" CPT. Anyway there were some fixes to do, for instance, double slash in the uri. I fixed it with this helpful post:

  • wordpress.stackexchange.com/questions/75157/how-to-fix-a-double-slash-in-custom-permalinks-with-hierarchical-taxonomys

I create all my code based on above two posts and put it in functions.php. You can see it in pastebin.

I thought, that everything works well until I’ve realized that there’re some problems with the manner that WordPress handle CPT top-categories and child-categories URIs. These are the problems:


This interior illumination's post:


When I click on breadcrumb link “Iluminación interior” of this post, it must show “Iluminación interior” archive page, in the following uri:


Instead of 404 Page not Found (Error 404: Página no encontrada). If I change manually browser's uri to:


404 Page not Found error disappear and everything works well.

If I remove 'hierarchical'=>true from 'rewrite' in function my_taxonomies_product() (you can find it above pastebin function.php code) and I click on breadcrumb link “Iluminación interior”, it shows archive page like I want but in the wrong uri:


"Interior illumination" (iluminación interior) is a subcategory of "Illumination" and the uri doesn’t show it, it should be: Root_domain/productos-decoracion/iluminacion/iluminacion-interior

This problems happens with all the other posts that have a top category and a subcategory.


The second problems comes when I click on breadcrumb link “Productos decoración” of many posts or categories pages, for instance here (Root_domain/productos-decoracion/iluminacion/iluminacion-interior/crea-ambientes-interior-acogedores ). Instead of bring to Root_domain/productos-decoracion (that’s what i want) it adds %field% to the end of the uri. %field% comes from functions.php code included above.

I've tried everything but with no success. I would really appreciate any help to fix this problems.

1 Answer 1


After many headaches, I've spent days and hours finding a solution. I've find a solution for two problems commented above. I hope it helps to someone:

PROBLEM 1: I realized that when I changed Permalink to Plain (wordpress admin > settings > permalink > Plain) and when I click in Breadcrumb link "iluminacion interior" it works OK (no more 404 error page). I tried the same in others subcategory's archive page and It works OK also. But I want "pretty permarlinks" I don't want this kind of url: ../?producto=crea-ambientes-interior-acogedores, so I’ve rewritten "/%category%/%postname%.html" in permarlinks > Custom Structure.

So the problem was that servers doesn't understand "pretty permalinks: /%category%/%postname%.html", then servers returns 404 error in subcategory's archives page when WordPress request this kind of url: rootdomain.es/productos-decoracion/iluminacion/iluminacion-interior To solve the problem I've added $newRules in function mmp_rewrite_rules in function.php, so the servers can understand WordPress requests. This is the new function mmp_rewrite_rules http://pastebin.com/AMELcM6r I've done the same for the other CPT Proyectos.

PROBLEM 2: This problem was easier to solve. I replace ‘has_archive’ => true, for ‘has_archive’ => ‘productos-decoracion’, in my_custom_post_product() function. ’productos-decoracion’ is the slug for the parent archive page. I do the same with proyectos CPT.

Now parent archive page url will be: …/productos-decoracion, no more .../productos-decoracion/%field%. Now we must create two file named: “archive-producto.php” and “archive-portfolio.php” (archive-CPT NAME.php) to show the content of parent archive pages. That’s all.

  • 1
    Any chance we can get an updated link? The paste has expired. Even better, if you could paste here or update your post :) Commented Feb 22, 2019 at 9:07

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.