wordpress默认的通用模板是archive.php模板,那么如何根据不同分类设置不同模板呢?简单介绍一下实现代码!
具体实现代码如下:
把原来的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不同分类(栏目)设置不同模板
版权声明:如发现本站有涉嫌抄袭侵权/违法违规的内容请联系客服!





