Change The Template For All Posts In A Specific Category

Categories have a lot of uses in WordPress. Not only can you use it to group certain posts about the same subject, sometimes we want to treat them differently. For example, on this website I have a few category of posts. Product pages need to be displayed differently than F.A.Q Posts. Luckily, we can easily manage to do this in our themes.

The script I developed adds a handy capability. It looks for files called in-category-{$slug} and includes that if a category of that post matches the file. To use this capability, add the following snippet to your theme’s functions.php file.