Title: Query string for multiple categories
Last modified: August 18, 2016

---

# Query string for multiple categories

 *  [Sivar](https://wordpress.org/support/users/sivar/)
 * (@sivar)
 * [19 years ago](https://wordpress.org/support/topic/query-string-for-multiple-categories/)
 * Hi,
 * I’d like to put a link on my page, which requests the latest say 20 posts from
   multiple categories (in fact, from all categories but cat1), so that The Loop
   gets that query.
    The thing is, I don’t want to use query_posts() because most
   of the time there are just posts from one category displayed by The Loop using“
   default” URLs like […]/category/mycategory/ and naturally I don’t want both.
 * What variables does the URL need, and what values? I know, that there is “cat
   =x”, but this only seems to work for one category, and excluding (“cat=-x”) doesn’t
   work either.
 * It seems, a second query and if-condition just before The Loop could solve my
   problem, like:
    `if (!is(category()) { $myquery = query_posts(); while ($myquery-
   >have_posts()) : $myquery->the_post(); ... endwhile; } else { The usual Loop }`
   But there has to be a more elegant way to do it…?
 * Any assistance would be very much appreciated, since I’m trying to figure that
   out for hours now *g*. Thanks in advance…
 * Sivar

The topic ‘Query string for multiple categories’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Sivar](https://wordpress.org/support/users/sivar/)
 * Last activity: [19 years ago](https://wordpress.org/support/topic/query-string-for-multiple-categories/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
