Title: Excluding categories within  query_posts
Last modified: August 19, 2016

---

# Excluding categories within query_posts

 *  [jupperpeep](https://wordpress.org/support/users/jupperpeep/)
 * (@jupperpeep)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/excluding-categories-within-query_posts/)
 * Hi
 * I’m wondering if anyone can give me any advice, I’m trying to create a secondary
   blog within my blog (if that makes sense), the idea is that I could have news/
   events announcements and then comments on related interests on other sites with
   a link.
 * I have created a new category for this and found a widget to display these posts
   as I do not wish them to appear within my regular posts which are reviews. My
   only sticking point is that I’m struggling to exclude this category from the 
   query for my other posts, the code snippet at present is as follows:
 * `<?php query_posts( 'cat=ID&showposts=2' ); ?>`
    and `<?php query_posts('cat=
   ID&showposts=1&offset=2'); ?>` and `<?php query_posts('cat=-ID&showposts=8&offset
   =3'); ?>`
 * I’m using the Equilibrium theme, and I have tried doing the following:
 * `<?php query_posts( 'cat=-5&showposts=2' ); ?>` (I think my new category has 
   an ID of 5)
 * I’ve also tried
 * `<?php query_posts( 'category__not_in=4&showposts=2' ); ?>`
 * and they don’t seem to be working. My website is [http://www.jadedeye.com](http://www.jadedeye.com)
 * Thanks
 * _[Please post code between backticks or use the code button]_

The topic ‘Excluding categories within query_posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jupperpeep](https://wordpress.org/support/users/jupperpeep/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/excluding-categories-within-query_posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
