在WordPress中不同分类使用不同的文章模板
发布时间:2022-06-22 04:03:13 所属栏目:教程 来源:互联网
导读:复制下段代码到single.php中,写文章时如果选择分类目录为solution,则该文章选择的模板为single-solution.php; 同理如果选择分类目录为product,则该文章选择的模板为single-product.php。 ?php if ( in_category(array(solution )) ) { get_template_part
复制下段代码到single.php中,写文章时如果选择分类目录为solution,则该文章选择的模板为single-solution.php; 同理如果选择分类目录为product,则该文章选择的模板为single-product.php。 <?php if ( in_category(array('solution' )) ) { get_template_part('single-solution' ); ![]() } elseif ( in_category(array('product' )) ) { get_template_part('single-product' ); } else { get_template_part('index' ); } ?> 。 (编辑:包头站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐