I have a problem with pagination.
when I select the filters created with wpgridbuilder, even if I go from 1300+ to only 70 products, I still see all the pages (from 1 to 46), instead of only seeing 3. maybe I’m wrong in declaring:echo paginate_links( array(‘total’ => $products->max_num_pages ?
<section class="full-width">
<div class="grid-1-3-m pad-tb">
<div class="facet-prod c-one">
<?php
wpgb_render_facet( [ 'id' => 1, 'grid' => 'wpgb-content' ] );
wpgb_render_facet( [ 'id' => 2, 'grid' => 'wpgb-content' ] );
wpgb_render_facet( [ 'id' => 3, 'grid' => 'wpgb-content' ] );
?>
</div>
<?php
$queried_term = get_queried_object();
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$args = array(
'post_type' => 'product',
'posts_per_page' => 30,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $queried_term->slug
)
),
'wp_grid_builder' => 'wpgb-content'
);
$products = new WP_Query( $args );
if( $products->have_posts() ):
echo '<div id="repeater" class="wpgb-content grid-5 c-three">';
while( $products->have_posts() ): $products->the_post();
$product = wc_get_product(get_the_ID());
$category = get_the_terms(get_the_ID(), 'product_cat')[0];
$price = $product->get_price();
$sale_price = $product->get_sale_price();
$title = get_the_title();
$titolo = $title;
$featured_image = get_the_post_thumbnail_url();
?>
<div class="box-prod">
<a class="box-prod__link clickable-parent" target="_self" href="<?php the_permalink(); ?>" aria-label="<?php echo $titolo; ?>">
<h2 class="box-prod__heading"><?php echo $titolo; ?></h2>
</a>
<a href="<?php echo get_term_link( $category ); ?>" class="box-prod__cat clickable-child"><?php echo $category->name; ?></a>
<img class="box-prod__featured" loading="lazy" src="<?php echo $featured_image; ?>" alt="<?php echo $titolo; ?>">
<p class="box-prod__price">
<?php
if ($sale_price) {
echo wc_price($sale_price);
} else {
echo wc_price($price);
}
?>
</p>
</div>
<?php
endwhile;
echo '</div>';
echo '<div class="main-pagination c-three">';
echo paginate_links( array(
'total' => $products->max_num_pages
) );
echo '</div>';
endif;
wp_reset_postdata();
?>
</div>
</section>