0

I'm running in a dilemma with something that should be very simple.

I have no custom post types. Just regulars posts. I just created a post with a category called "news". The official documentation says that defining a template for that category should be as simple as creating a category-news.php file inside the theme.

However it does not work, it keeps using the single.php file. What am I doing wrong?

1 Answer 1

1

If you take a look at Template Hierarchy category-news.php would be archive template, that is for a list of multiple posts having specific category.

There is no such thing as template for individual post, having specific category, in native template hierarchy.

There are different ways to handle such, depending on your needs. Typical are:

  • styling it via CSS (WP tends to output a lot of useful body classes to use)
  • handling markup conditionally inside template file
  • adding your own template file logic to native hierarchy
2
  • Er wait a moment.. If he has only one post in the category 'news' and he has a menu pick for category = news, why doesn't that work? Clearly a menu pick for a single post won't work, but a menu selection for category = news should totally nail it. Also, probably best to verify the slug name for the category is what you think it is.
    – zipzit
    Commented Jun 13, 2014 at 7:07
  • @zipzit it would work for archive, but that's no "alternative" to actual singular view
    – Rarst
    Commented Jun 13, 2014 at 7:52

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.