1

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' ) ) {
                wp_pagenavi();
            }; 
        } endif;?>
    

How to fix paging?

| improve this question | | | | |
  • How do you fetch the posts before the first have_posts() call? – fuxia 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. – fuxia Jul 29 '12 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.