Title: Exclude category from query_posts
Last modified: August 20, 2016

---

# Exclude category from query_posts

 *  Resolved [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/)
 * I’m having trouble with this, and have searched the Forum for about an hour. 
   I see many ‘similar’ issues, but not this one in particular. I think my problem
   stems from the use of the array here (but, obviously, I’m not sure).
 * I have this line of code in home.php
 * `<?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged'
   => get_query_var( 'paged' ) ) ); ?>`
 * I want to exclude the category with the ID ’10’
 * How do I edit that query_post line to accomplish this?
 * Thanks!

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/exclude-category-from-query_posts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/exclude-category-from-query_posts/page/2/?output_format=md)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919794)
 * `<?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged'
   => get_query_var( 'paged' ), 'cat = -10' ) ); ?>`
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919800)
 * see all query parameter:
    [http://codex.wordpress.org/Class_Reference/WP_Query#Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Parameters)
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919811)
 * Thanks for your reply esmi, but category 10 is still showing up in the main feed
   when I do it that way. I think I’m getting closer, using some info from that 
   link, alchymyth, but not quite there yet. I’ve excluded category 10, but now 
   the posts are showing up in reverse order (by date, oldest to newest). So I tried
   this:
 * `<?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged'
   => get_query_var( 'paged' ), 'orderby' => 'date', 'order' => 'ASC', 'category__not_in'
   => array( 10 ) ) ); ?>`
 * Still not affecting the order, whether I use ASC or DESC Showing up oldest-to-
   newest. I’m sure I’m missing something simple?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919813)
 * The main feed? Are we talking about an RSS feed or a posts page?
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919838)
 * Sorry, main “posts page,” as in the main blog home page. I know I’m probably 
   using incorrect terms!
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919850)
 * Try `'order' => 'DESC'`
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919860)
 * Yeah, I’ve tried both ASC and DESC in that position, but it doesn’t change anything.
   The posts still show up oldest-to-newest. Weird.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919866)
 * Is this the only query on the page or do you have other loops running?
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919872)
 * That is the only one.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919883)
 * So nothing in other template files on the same page – such as sidebar.php, header.
   php etc?
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919887)
 * No, I even did a multi-file search of all the MAIN template files, as well as
   the CHILD template files (which I’m working on), and that is the ONLY instance
   of query_posts. It appears in home.php, and nowhere else :/
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919889)
 * Is this a custom page template?
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919894)
 * no, it’s a standard page template, and that’s the only line I’ve edited on that
   page.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919895)
 * where did you download the theme from?
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/#post-2919901)
 * It’s from Theme Hybrid [http://themehybrid.com/](http://themehybrid.com/)
 * Maybe I should start in their Forum next, and see if I can get something there…

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/exclude-category-from-query_posts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/exclude-category-from-query_posts/page/2/?output_format=md)

The topic ‘Exclude category from query_posts’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 17 replies
 * 3 participants
 * Last reply from: [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/exclude-category-from-query_posts/page/2/#post-2919959)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
