Different Categories Use Different Templates In WordPress

Different Categories Use Different Templates In WordPress

Three new categories are created : news, events and blug. If I want to use different templates for different categories, how to achieve this? category.php in the theme will be used as template file for category by default in WordPress and single.php will be used as template for a single post. At this time, we just need to create three files in the same directory of category.php file: category-news.php,category-blog.php,category-events.php we can also create the php file by category ids. If the corresponding IDs of the categories are 1,2,3,we just need to create the files: category-1.php,category-2.php,category-3.php These template files will be automatically invoked when we visit the categories.