Title: query_posts breaks paging
Last modified: August 18, 2016

---

# query_posts breaks paging

 *  [tiszenkel](https://wordpress.org/support/users/tiszenkel/)
 * (@tiszenkel)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/query_posts-breaks-paging/)
 * I’m using multiple loops on the index of my week-old blog — three of them, in
   fact. Here, check out the site and I’ll explain what’s happening:
 * [http://www.queenscentral.com/](http://www.queenscentral.com/)
 * The first loop is to display just the most-recent post. I used query_post to 
   limit the loop to the most recent and exclude all posts from a certain category:
 * `<?php query_posts('showposts=1&cat=-4'); ?>`
 * The second loop is directly below, to display the three most recent posts from
   _only_ the category I excluded in the first loop. This, of course, is an “Asides”-
   type of feature. It’s specified with this code:
 * `<?php query_posts('showposts=3&cat=4'); ?>`
 * And the final loop just displays the rest of the posts, but again, without category
   4, my Asides category:
 * `<?php query_posts('offset=1&cat=-4'); ?>`
 * The problem here is that when I get to the point where paging is necessary, the
   next pages just display the same posts as the first page. (You can’t see that
   in action right now because I temporarily dialed up the number of posts that 
   display per page in order to avoid this issue.) What I _want_ to happen is for
   the second page to display the next posts — minus category 4 — in the same format
   as the third loop in the index. No first loop, no second loop. How do I do this?
   All the information I’ve come across suggests that query_posts breaks paging,
   but I haven’t seen any fixes that pertain to my specific case.
 * Here’s a year-old support post that comes closest to answering my question, but
   still, the solution given doesn’t work:
 * [http://wordpress.org/support/topic/69319](http://wordpress.org/support/topic/69319)
 * I suspect that’s because my index is a little more complex — I have multiple 
   query_posts statements, and each of them has more than one parameter. But I figured
   I’d cite it because it seems to be a start.
 * Can anyone help?

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

 *  [nicjohnson](https://wordpress.org/support/users/nicjohnson/)
 * (@nicjohnson)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/query_posts-breaks-paging/#post-557228)
 * Same problem… Anyone, please?
 *  [azsportshub](https://wordpress.org/support/users/azsportshub/)
 * (@azsportshub)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/query_posts-breaks-paging/#post-557240)
 * I think that this support topic should resolve your issue:
 * [http://wordpress.org/support/topic/38210?replies=16](http://wordpress.org/support/topic/38210?replies=16)
 * However,I am having problems implementing it on my second blog and am quite baffled:
 * [http://wordpress.org/support/topic/133026?replies=1#post-611803](http://wordpress.org/support/topic/133026?replies=1#post-611803)
 *  [alinam](https://wordpress.org/support/users/alinam/)
 * (@alinam)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/query_posts-breaks-paging/#post-557246)
 * I’ve had the same problem for a bit, but have found the solution (which worked
   for me, and in theory should work for you as well). It is in fact mentioned in
   the [query_posts](http://codex.wordpress.org/Template_Tags/query_posts) tag page–
   but only once.
 * > Place a call to query_posts() in one of your Template files before The Loop
   > begins. The wp_query object will generate a new SQL query using your parameters.
   > When you do this, WordPress ignores the other parameters it receives via the
   > URL (such as page number or category). **If you want to preserve that information,
   > you can use the variable $query_string in the call to query_posts()**.
 * As an example:
 * <?php query_posts(**$query_string.**‘**&**cat=4′); ?>
 * Note the use of ‘&’ at the start of the quoted portion of the argument.
 * Hope that helped.
 *  [dizzy100](https://wordpress.org/support/users/dizzy100/)
 * (@dizzy100)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/query_posts-breaks-paging/#post-557252)
 * Oh this was doing my head in, now, thanks to you alinam, this is fixed. Perfect
   solution, many thanks.

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

The topic ‘query_posts breaks paging’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 5 participants
 * Last reply from: [dizzy100](https://wordpress.org/support/users/dizzy100/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/query_posts-breaks-paging/#post-557252)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
