0

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(); ?>
2
Contributors
1
Reply
9
Views
1 Year
Discussion Span
Last Post by diafol
0

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.

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.