Today I learned about category templates in WordPress. There is a simple, yet rarely used feature, that allows you to display content based on a specific category. For example, if you have 10 categories, with ID’s 1-10, and you want to show your visitors something different for each of these 10 categories, you can create files with this naming convention:
category-1.php, category-2.php, and so on.
When the URL http://mydomain.com/category/coolcat is entered into the browsers address bar, and WordPress sees a category request made, it looks for a category-x.php file in the main template folder. If one exists, that will be used over the default template file. If a template file isn’t found for the requested category, the next file that WordPress looks for is category.php. This is another template default file that can be applied to all categories that don’t have their own template. If a category.php isn’t found, then the default template file is used.
One thing I discovered while trying to get category templates to work, I was entering http://mydomain.com/coolcat and expecting the category template to display. But as you may know, WordPress was trying to find a Page named “coolcat”. I struggled with this for a week, and after ripping out the small hair follicles on my head, it dawned on me I was entering the wrong URL. Remember, /category/ must precede the category name, or it just doesn’t work.
Here is a link to the WordPress Codex explaining category template.