这是模板。我的类别 slug 是“新闻”,类别 id 是 40。我将 php 文件命名为 category-news.php 和 category-40.php。这两个文件都提供了正确的模板,但是当我想要的只是单个类别时,它会显示所有类别。为了显示单个类别,我必须更改什么?
<?php
/*
Template Name: Category PAGE
*/
get_header();?>
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
$blog_style = $hana_post_meta['blog_style'];
if($blog_style=='fluid') $hana_page_options['layout'] = 'full';
?>
<div class="blog-container <?php echo $blog_style;?>-blog">
<div id="content" class="<?php echo ($blog_style!='fluid')?vintage_content_class():'';?>">
<?php
//query posts
$postsPerPage=hana_get_opt('_post_per_page_on_blog')==''?5:hana_get_opt('_post_per_page_on_blog');
$excludeCat=explode(',',hana_get_opt('_exclude_cat_from_blog'));
query_posts(array(
'category__not_in' => $excludeCat,
'paged' => get_query_var('paged'),
'posts_per_page' => hana_get_opt('_post_per_page_on_blog')
));
$blog_loop = array();
$blog_loop['layout'] = $hana_page_options['layout'];
$blog_loop['column'] = $hana_post_meta['blogcolumn'];
get_template_part( 'loop', $blog_style );
wp_reset_query();?>
</div>
<?php get_sidebar();?>
<?php vintage_get_addtional_products(); ?>
</div><?php
endwhile; endif;?>
<?php get_footer(); ?>