WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have custom post template archive-product.php for custom post type "product".

In this template paging does not work:

  • numbers are displayed
  • all numbers links redirect to first page

        <?php if (($numParent) == 4) {?>
        do stuff
        <?php } elseif (($numParent) == 3) { 
            $paged = 1;  
            if ( get_query_var('paged') ) $paged = get_query_var('paged');  
            if ( get_query_var('page') ) $paged = get_query_var('page'); 
            query_posts = array('post_parent'=> $post->ID, 'post_type'=>'product','paged' => $paged, 'posts_per_page' => 10); 
            while ( have_posts() ) : the_post();?>
                do stuff
            <?php endwhile; ?>
            <?php if ( function_exists( 'wp_pagenavi' ) ) {
        } endif;?>

How to fix paging?

share|improve this question
How do you fetch the posts before the first have_posts() call? – toscho Jul 29 '12 at 20:40
there are just header.php and sidebar.php before the first have_posts(). – sergeydyadyul Jul 29 '12 at 21:39
So you don’t even set the main query? Pagination cannot work as you expect it. Read about query_posts() and its alternatives to see the difference. – toscho Jul 29 '12 at 21:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.