我一直在谷歌上寻找如何在不使用插件的情况下从博客中排除类别的答案。
我想出了这个:
<?php query_posts('cat=-2'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php //comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
但这并不排除类别ID为2的博客文章。能澄清一下原因吗?
试试这个:
query_posts($query_string . '&cat=-2');