H
H
hellion352020-04-15 10:25:51
WordPress
hellion35, 2020-04-15 10:25:51

Woocommerce pagination not working?

Hello. I display products from Woocommerce via WP_Query (), the design is as follows:

$category = get_queried_object();
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$args = array(
     'post_type'         => 'product',
     'paged'             => $paged,
     $category->taxonomy => $category->slug,
);
$posts = new WP_Query($args);
if($posts->have_posts()):
     while($posts->have_posts()): $posts->the_post();
          get_template_part( 'templates/content/product-cat', 'product-cat' );
     endwhile;
wp_reset_postdata();
endif;

Below I am trying to display pagination using the_posts_pagination() function . Nothing is displayed on the page at all, I tried not to interfere with the standard WP_Query () at all, that is, the design was like this:
if(have_posts()):
     while(have_posts()): the_post();
          get_template_part( 'templates/content/product-cat', 'product-cat' );
     endwhile;
wp_reset_postdata();
endif;

I also don’t want to display pagination, although in $paged I get int(1) , and in $posts->max_num_pages I have float(2) , I tried to use kama_pagenavi() , pagination is displayed but when I go to the second page they are displayed the same items as the first one. Tell me please, what could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question