Title: query_post Pagination Problem
Last modified: August 19, 2016

---

# query_post Pagination Problem

 *  [benherbert](https://wordpress.org/support/users/benherbert/)
 * (@benherbert)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/query_post-pagination-problem/)
 * Hi,
 * I have created a category on my wordpress installation which is called new arrivals.
   Now in this category I want to show ALL posts from all my other categories – 
   kind of like what you would find on your homepage. So I created a new category
   template file called category-new-arrivals.php and then put this code in it:
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;  
   
       query_posts(array(
       'paged'	=> $paged,
       'category__not_in' => array(-1),
       'posts_per_page' => 50,
       ));
       ?>
       ```
   
 * When I load the category the first page works fine, as it shows 50 items (default
   is 40) and posts from every category (minus the one excluded).
 * However when I move to /new-arrivals/page/2/ I get a 404 not found page even 
   though I check for the page number at the start and use it in the query_posts
 * Can anyone explain why this is happening and how to fix it?
 * Thanks

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

 *  Thread Starter [benherbert](https://wordpress.org/support/users/benherbert/)
 * (@benherbert)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/query_post-pagination-problem/#post-1681155)
 * Must add that the new arrivals category is obviously blank and not filled with
   any posts because I thought I could overwrite the query every page load to show
   what I wanted.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/query_post-pagination-problem/#post-1681438)
 * You don’t need a negative value for data fed into `category__not_in`, it’s an
   exclusion parameter so it simply expects IDs..
 * You only need negative values when using `cat` which accepts both inclusions 
   and exclusions.
 * Regarding the paging problem, does the same problem occur using default permalinks,
   ie. off? (read on first though).
 * NOTE: By doing this..
 *     ```
       query_posts(array(
       'paged'	=> $paged,
       'category__not_in' => array(-1),
       'posts_per_page' => 50,
       ));
       ```
   
 * You’re not correctly preserving any existing query variables..
 * Try this instead..
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;  
   
       query_posts( array_merge( $wp_query->query, array(
           'paged'	=> $paged,
           'category__not_in' => array(1),
           'posts_per_page' => 50
       ) ) );
       ?>
       ```
   

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

The topic ‘query_post Pagination Problem’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/query_post-pagination-problem/#post-1681438)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
