0

I added category-news.php template file to the theme directory but it doesn't apply the template of the category but instead to the index.php file.

category-slug.php is the highest level of the template heirarchy of WordPress so it should accept the file. I tried also category-id.php and it also doesn't work. The same for archives template files.

However, when I use single-slug.php or page-slug.php it's working without any problems.

I checked that there is not any conflicts with the permalinks, it's a parent category with the slug news and the class of the page of the category is category-news. What can cause this problem?

  • What does "doesn't work" mean? What code is in this template? – Jacob Peattie Apr 2 '19 at 12:38
  • It doesn't apply the template of the category as it should. I edited the question. – Yossi Aharon Apr 2 '19 at 12:59
  • is this an actual category archive? Or a page template with a query_posts call at the top? – Tom J Nowell Apr 2 '19 at 13:11
  • It's an actual category archive. – Yossi Aharon Apr 2 '19 at 14:17
  • Everything you've described should work unless you're going to the wrong url or the term or taxonomy has an issue. Can you try flushing your rewrite rules by going to Settings > Permalinks and clicking save? – MikeNGarrett Apr 3 '19 at 3:13
-1

I do not understand your question very much, but if it is a category the template file should be named for taxonomy-category-news.php or taxonomy-category_news.php

| improve this answer | |
  • It's not a taxonomy of custom post type, it's a category archive. – Yossi Aharon Apr 2 '19 at 14:19

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.