打开模板目录wp-content\themes\yourtheme文件夹
先复制一份category.php
,命名为category-all.php
然后修改category.php
如下
[php]<?php
$post = $wp_query->post;
if ( in_category(array( 9,10,11,12,13,14 )) ) {
include(TEMPLATEPATH . ‘/category-library.php’);
}
else if ( in_category(‘1’) ) {
include(TEMPLATEPATH . ‘/category-1.php’);
}
else if ( in_category(‘4’) ) {
include(TEMPLATEPATH . ‘/category-4.php’);
}
else if ( in_category(‘8’) ) {
include(TEMPLATEPATH . ‘/category-8.php’);
}
else {
include(TEMPLATEPATH . ‘/category-simple.php’);
}
?>
[/php]
上面代码表示:
分类ID为“9,10,11,12,13,14”,使用category-library.php模板文件(即复制修改前的category.php,然后自己修改)
分类ID为“1”使用category-1.php模板文件
分类ID为“4”使用category-4.php模板文件
分类ID为“8”使用category-8.php模板文件
其他的则使用category-simple.php模板文件。