How do I show all posts but exclude a specific category on wordpress?

I have this code that right now spits out all the posts regardless of category.

<?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 ?>

How Do I do the same thing, except exclude posts with a category ‘blog’?

Related posts

Leave a Reply

2 comments

  1. You can use below thing :-

    $query = new WP_Query( 'cat=-12,-34,-56' );
    

    OR

    $query = new WP_Query( array( 'category__not_in' => array( 2, 6 ) ) );
    
  2. I found the answer! You had to do replace

    query_posts( $query_string . '&ignore_sticky_posts=1' );
    

    with

    query_posts( $query_string . '&ignore_sticky_posts=1&cat=-' . get_cat_ID( 'Blogs' ) );