Title: query_posts issue, can&#8217;t exclude categories
Last modified: August 19, 2016

---

# query_posts issue, can’t exclude categories

 *  [arve-systad](https://wordpress.org/support/users/arve-systad/)
 * (@arve-systad)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/)
 * Hi, i’m having a tiny struggle with the query_posts() function.
 * `query_posts('showposts=2'); while (have_posts()) : the_post(); ?> [post-content-
   stuff]`
 * Works like a charm. When i add _&cat=-19_ to the query_posts parameter, it only
   returns the two very first posts ever to be posted, not the two last ones – which
   results in my front page showing over four year old posts.
 * Why is this? It seems to work just fine for everyone else wanting to exclude 
   a category, so i must obviously be doing something wrong…

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/#post-879829)
 * What version of MySQL is in use on your host?
 * Wonder what happens if you use the **order=DESC** parameter?
 * Resource: [template tag](http://codex.wordpress.org/Template_Tags), [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts)
 *  Thread Starter [arve-systad](https://wordpress.org/support/users/arve-systad/)
 * (@arve-systad)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/#post-879926)
 * My host runs MySQL 5, and the order=DESC (alone and along with orderby=date) 
   has no effect. Also tried adding all the parameters as an array, with the same
   result. :\
 *  Thread Starter [arve-systad](https://wordpress.org/support/users/arve-systad/)
 * (@arve-systad)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/#post-879933)
 * Ok, i did it the other way around. Stupid way to do it really, but since i’ll
   probably never add more categories, so it’s not a big issue.
 * cat=1,2,3,4,5…. – adding all, except the one i want to exclude worked. 🙂
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/#post-879938)
 * Note, there is a known bug with MySQL 5.0.51 (and maybe other versions).
 * Should have pointed to this before:
    [http://wordpress.org/support/topic/154622](http://wordpress.org/support/topic/154622)
 *  Thread Starter [arve-systad](https://wordpress.org/support/users/arve-systad/)
 * (@arve-systad)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/#post-880072)
 * Aah, I see. Well, then i know the reason why, so i’m pleased. Thanks a lot 🙂

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

The topic ‘query_posts issue, can’t exclude categories’ is closed to new replies.

## Tags

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

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 5 replies
 * 2 participants
 * Last reply from: [arve-systad](https://wordpress.org/support/users/arve-systad/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-issue-cant-exclude-categories/#post-880072)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
