Create Post Template by Category

The page template capability of a Page in WordPress is simply amazing, and sometimes you need that feature in a post. The time will come that you will be needing a single post to have it’s own template that depends on its category or tags.

This guideline works by giving a condition to the post and choosing the right page template.   Paste the code below to single.php of your WordPress template.

In the example above, I’ve given a condition that when the post is under the category id = 1 the template will use single1.php and same way with the other condition. In short, you have to create each template.

Creating post type by category is not only limited to “by category conditions”,  you can give conditions on tags, custom taxonomies,  and more. Check out the conditional tags on wordpress codex for more options.