To realize the use of different styles for different categories of WordPress, the general practice is to create multiple category templates, and make corresponding calls through the corresponding category ID or category alias, or use
is_category()The function to judge and call (refer to the tutorial "How to call different templates in different WordPress categories"), the operation is more complicated, and the implementation of the Custom Category Templates plug-in can avoid these steps.
The Custom Category Templates plugin is a wordpress plugin that can freely select category templates and call different display styles. Users place the prepared category template php file in the current theme root directory. After enabling the plugin, select the template in the category directory editing interface. Can.
1. Download the plugin: WordPress official plugin center (or contact the site administrator)
2. After uploading and installing the plugin successfully, enable the plugin
3. Put the prepared classification template php file in the root directory of the currently used theme, and put the first line of the file in the
<?phpReplace with the following code:
<?php /* Template Name: 自定义模板 */
Tip: Change the template name "Custom Template" to a name you like, and the names of different templates are different.
4. Enter the website background - article - category directory, edit the category that you want to call different templates, and select the template you want to call in the drop-down of "Category Templates"
5. Finally, click Save.
Of course, you can study the code of the plugin and inherit this functionality into your current theme.