I do know that this question has been asked before, but I'm writing because the solutions I have found didn't work.

So, I have a lot of posts with 'post_type' = 'post' that are filtered by a category taxonomy. The category taxonomy has some slugs that are hierarchical, while some of the others are not. I need to create a taxonomy template for each category.

So, for example, I have the following categories:

  1. Events
  2. Case Study (This has children categories such as Public, Health, etc) - All children will use the same template as the parent, in this case, the case study template
  3. Reports

Now, I've read on the documentation and on a lot of questions asked on stackexchange different ways of naming the taxonomy template file.

I've tried most of the naming of files including the following:

  • taxonomy-category-{slug}.php
  • taxonomy-category.php
  • category-{slug}.php
  • category-{ID}.php
  • taxonomy.php

The post still uses the index.php template to display the post instead of any of the taxonomy created files.

In the wp_term_taxonomy table, I noticed the existence of multiple taxonomies with the same name (in this case category), all with a different ID, of course. The count on them is different, but adding all of them together don't add up to the amount of posts that I currently have. I'm not sure if this might be the issue (Maybe it doesn't know which taxonomy to use when there are multiple ones).

Anyone has any suggestions regarding this?

1 Answer 1


The post won't use those templates because those aren't intended for posts. They're intended for the archive pages for those terms/categories/tags.

What's more, it doesn't make sense for it to work that way as it introduces ambiguity. Case in point, if I have category-red.php and category-blue.php, which template gets loaded if I visit a post that's in both red and blue categories?

Instead, take a look at the template hierarchy diagram, you'll very likely need to implement a check in your posts template yourself. Also consider adding a single.php, and post.php template to your theme

  • Ok, I understand now. I see how it can introduce ambiguity. So the solution would be to have a single.php file that basically handles the design of each taxonomy page by checking what category the loading post is. Basically a big file.
    – Sebastian
    Mar 5, 2020 at 9:16
  • 1
    The solution you have provided with the single.php file that implements a check and loads the template based on the category is exactly what I was looking for. It's a great workaround. Thank you!
    – Sebastian
    Mar 5, 2020 at 11:31

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.