Title: exclude a category from query posts
Last modified: August 19, 2016

---

# exclude a category from query posts

 *  Resolved [oldbag66](https://wordpress.org/support/users/oldbag66/)
 * (@oldbag66)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-catagory-from-query-posts/)
 * hi, im making my own dynamic sidebar and i just want to exclude a category from
   this script, any help would be appreciated:
 *     ```
       <div class="widget">
       <?php query_posts('showposts=10'); ?>
       <li>
       	<h3>Latest News</h3>
       	<ul>
       		<?php while (have_posts()) : the_post(); ?>
       		<li><a href='<?php the_permalink() ?>'><?php the_title(); ?></a></li>
       		<?php endwhile; ?>
       	</ul>
       </li>
       </div>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-catagory-from-query-posts/#post-1026858)
 * The [template tag](http://codex.wordpress.org/Template_Tags), [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts),
   has a **cat=-7** argument. Replace the 7 with your category ID.
 *  Thread Starter [oldbag66](https://wordpress.org/support/users/oldbag66/)
 * (@oldbag66)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-catagory-from-query-posts/#post-1026880)
 * ok that makes sense, i actually need to exclude it from this code (sorry my mistake)
   and not sure how to add the cat exclusion
    `<?php wp_list_categories('show_count
   =1&title_li=<h3>News Categories</h3>'); ?>`
 * i tried this but it doesnt work, am i close!:
 * `<?php wp_list_categories('cat=-13&show_count=1&title_li=<h3>News Categories</
   h3>'); ?>`
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-catagory-from-query-posts/#post-1026889)
 * The [template tag](http://codex.wordpress.org/Template_Tags), [wp_list_categories()](http://codex.wordpress.org/Template_Tags/wp_list_categories),
   uses an **exclude=** argument (with NO minus sign).
 *     ```
       <?php wp_list_categories('exclude=13&show_count=1&title_li=<h3>News Categories</h3>'); ?>
       ```
   
 *  Thread Starter [oldbag66](https://wordpress.org/support/users/oldbag66/)
 * (@oldbag66)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-catagory-from-query-posts/#post-1026892)
 * thats great thank-you very much.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘exclude a category from query posts’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [oldbag66](https://wordpress.org/support/users/oldbag66/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-catagory-from-query-posts/#post-1026892)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
