我有这个代码,现在吐出所有的帖子,不管类别。
<?php /* Start the Loop */ ?>
<?php global $query_string;
query_posts( $query_string . '&ignore_sticky_posts=1' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; // end of the loop. ?>
<?php wp_reset_query(); // reset the query ?>
我如何做同样的事情,除了排除与类别"博客"的帖子?
你可以使用下面的东西:-
$query = new WP_Query( 'cat=-12,-34,-56' );
或
$query = new WP_Query( array( 'category__not_in' => array( 2, 6 ) ) );
我找到答案了!你必须使用replace
query_posts( $query_string . '&ignore_sticky_posts=1' );
query_posts( $query_string . '&ignore_sticky_posts=1&cat=-' . get_cat_ID( 'Blogs' ) );