Different Categories Use Different Templates In WordPress

2019-04-12 0 Comments Views

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:


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:


These template files will be automatically invoked when we visit the categories.

Related Posts


My Wechat: dongyangyemao Email: dongyangyemao#qq.com

Article Comments(0)