OK, so i'm messing with Custom Taxonomies for the second time and in both instances i've run into this problem where using the posts_per_page argument in either a query_posts or WP_query scenario.. basically, if i set a custom limit on posts per page, clicking the "next" or "previous" buttons give me 404 errors .. doesnt matter if i use a custom permalink structure or any of the defaults, same result. the only way ive successfully managed to control number of posts on a page is through the Reading Settings in the Dashboard.

i've found quite a few mentions of this same problem but have yet to find a working solution aside from above mentioned Dashboard settings:




so, here's the site im working on with the problem:

http://www.purekreation.com (click on any of the sections in the nav and then try to navigate to previous pages at the bottom)

and here's my current (non-working) code:

    <?php get_header(); ?>

    <div id="art">

        <?php global $query_string, $paged, $wp_query, $wp;
        $count = 0;
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        echo $paged;
        <?php $term = get_query_var('term'); echo $term;?>
        <?php $tax = get_query_var('taxonomy'); echo $tax;?>
        $taxquery=new WP_Query(array('tax_query'=>array(array('taxonomy'=>$tax,'field'=>'slug','terms'=>$term)),'post_type'=>'art','showposts'=>1,'paged'=>$paged));
        while ( $taxquery->have_posts() ) : $taxquery->the_post(); ?>

    <?php $genre = wp_get_post_terms($post->ID, 'genre');?>
        <div id="post-<?php the_ID(); ?>" <?php post_class('post-'.$genre[0]->slug.' post-art');?>> 
            <h3 class="work-title"><?php the_title();?></h3>
            <?php get_the_10(); ?>
            <div class="the-content">
                <?php the_content(); ?>
            <footer class="COL-10 clear">
                <small class="post-meta"><?php $terms = get_the_term_list( $post->ID, 'genre', 'Portfolio: ', ' ', '' );  echo $terms;?></small>
                <small class="post-meta">Project: <?php the_tags( '',', ','');?></small>
                <small class="post-meta">Client: <?php $meta = get_post_meta($post->ID, 'client', true); if($meta==''){echo 'Self';}else{echo $meta;}?></small>
                <small class="post-meta right"><a href="#masthead">Back to top</a></small>
                <div class="dash"></div>
        </div><!-- #post-## -->    
        <?php $count++; ?>
        <?php endwhile; ?>
                        <div id="nav-below" class="pagination">
        <?php if($taxquery->max_num_pages>1){?>
                    <a href="<?php bloginfo('url');?>/?<?php echo $tax;?>=<?php echo $term;?>&<?php echo 'paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
                    <a href="<?php bloginfo('url');?>/?<?php echo $tax;?>=<?php echo $term;?>&<?php echo 'paged=' . $i; //next link ?>">></a>
            <?php } ?>
    <?php } ?>
            <?php // Reset Post Data
             // End the loop. Whew.?>
    </div><!-- end #art -->
    <?php get_footer(); ?>

im not the most skilled PHP guy but i know a decent amount about Wordpress and this problem has me literally losing sleep over it. if anyone has some input on this matter, it'd be GREATLY appreciated.

1 Answer 1


should it be..

$paged = (get_query_var('page')) ? get_query_var('page') : 1;

WP_Query in codex:

Pagination Note: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.

  • THANK YOU SO MUCH, that was indeed the issue! LTFOL why is it always the little things? the devil is most definitely in the details :P May 4, 2011 at 17:36
  • 1
    I ran into a similar problem with WP 3.2.1 and I had to use "paged" instead of "page". "page" was empty but "paged" would return the correct number. My URL structure is example.com/category/category-slug/page/3
    – Ian Dunn
    Sep 13, 2011 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.