I am having issues creating a custom page template for a category in WP. I am currently using the standard content type "post".

So the issue is I have a parent category, and many sub categories and I would like any posts within these categories to use a specific layout. This custom template should apply to all sub categories within the parent. Is this possible, or would I need to create separate templates for each sub category?

I have looked at custom post types as another option, but It doesn't seem they have the hierarchy options required.

Any advise would be appreciated

  • You could use the template_include hook for Posts, or look further into CPTs - what hierarchy are you trying to achieve? stackoverflow.com/questions/3114934/…
    – WebElaine
    Mar 14, 2018 at 13:12
  • Thanks, I may look deeper into CPTs, I did try the option to use the existing categories from core WP, but it seemed to flatten them
    – Pilgrimiv
    Mar 14, 2018 at 13:16

1 Answer 1


Have a look at this article in the the WordPress Theme Developer Handbook.

You should create a template in your theme named category-unicorns.php where unicorns is the slug for the parent category you want this template to be used for. You can also create a template file category-5.php where 5 is the id of the parent category.

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.