用wordpress做网站特别是企业网站建设的时候,多个分类的内容不同需要显示的页面也不一样,比如有些分类显示的是产品缩略图,有些显示的是公司新闻公告等,此时需要不同的分类模板。
虽然wordpress默认只有一个通用的分类目录模板(archive.php),但是可以通过函数代码实现不同的分类调用不同的模板。
实现wordpress不同分类调用不同模板的方法:
<?php if (is_category(array(3,17,18,19,20,21,22,23))){ include(TEMPLATEPATH . '/list_pro.php'); }elseif (is_category(array(5,7,8,6))){ include(TEMPLATEPATH . '/list_news.php'); } elseif (is_category(array(2,10))){ include(TEMPLATEPATH . '/index_about.php'); } elseif (is_category(array(14))){ include(TEMPLATEPATH . '/list_yijiao.php'); } elseif (is_category(array(11))){ include(TEMPLATEPATH . '/index_lishi.php'); } elseif (is_category(array(12))){ include(TEMPLATEPATH . '/index_about.php'); } elseif (is_category(array(13))){ include(TEMPLATEPATH . '/list_zhengshu.php'); } elseif (is_category(array(4,15))){ include(TEMPLATEPATH . '/index_fuwu.php'); } elseif (is_category(array(16))){ include(TEMPLATEPATH . '/index_wenda.php'); } elseif (is_category(array(9))){ include(TEMPLATEPATH . '/index_lianxi.php'); } else{ include(TEMPLATEPATH . '/1.php'); } ?> |
<?php if ( in_category(array( 3,17,18,19,20,21,22,23 )) ) { get_template_part('active_pro' ); } elseif ( in_category(array( 5,7,8,6 )) ) { get_template_part('active_news' ); } else { get_template_part('active_news' ); } ?> |
版版权所有:郑州非凡在线电子技术有限公司 2006-2017 www.idcff.com 工信部ICP备案:豫ICP备11006451号 全国24H销售热线(TEL):15538013776
Copyright @ 2008-2015 idcff All Rights Reserved