
wordpress默认的通用模板是archive.php模板,那么如何根据不同分类设置不同模板呢?下面web建站小编给大家简单介绍一下实现代码!
具体实现代码如下:
把原来的archive.php通用模板复制到category-other.php,把下面内容添加到archive.php模板中,再根据需求新建其它模板。
<?php
if (is_category(array(1,2,3))){
//分类id=1,2,3调用category-123模板
include(TEMPLATEPATH . '/category-123.php');
}elseif (is_category(array(4,5,6))){
//分类id=4,5,6调用category-456模板
include(TEMPLATEPATH . '/category-456.php');
}else{
//其它分类调用category-other
include(TEMPLATEPATH . '/category-other.php');
}
?>
wordpress建站如何快速提交和优化您的网站(IndexNow插件)?
标签: wordpress技巧, wordpress模板
上面是“wordpress不同分类(栏目)设置不同模板”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3683.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

把textarea内容插入到div中不会换行
ColorJoyful