When I use pagination for custom post type 'product' its working fine but its not working for the categories of custom post type. for ex. pagination working for this 'http://localhost/wordpress/products/page/2/' and not for this 'http://localhost/wordpress/products/landscape/page/2/' its always showing the first page content. How to solve this? given below is my code.

  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'product', 'posts_per_page' =>1,'taxonomy' =>'product_cat','term' => $cat_name1,'orderby'=>'post_date','page'=>$paged );
    $wp_query = new WP_Query($args);
    if($wp_query->have_posts()) : while ($wp_query->have_posts()): $wp_query->the_post();

    <div class="product_list">
    <?php the_title();?>
    </div>
    <?php endwhile; ?>
    <?php wp_pagenavi( array( 'query' => $wp_query ) );//plugin code ?>
    <?php else : ?>
    <!-- No posts found -->
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
    <?php echo "No Products found for this categoy!." ?>
    </div>
    <?php endif; ?>
    <?php wp_reset_query(); ?>
Member Avatar for diafol

Not sure, but looks like it doesn't recognise $paged when on product categories. WHere does $cat_name1 come from?

Maybe echo out the vars to see what's being passed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.