• 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

    (@benherbert)

    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.

    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.