I'm having custom page template that I use as front page of my theme. In that page i have section which lists woocommerce products using custom loop. I want to insert next posts pagination to that section. I'm using next_posts_link() function to generate next page url link. It generates this perfectly, but on my home page page/2 isn't displaying new products but old ones.
Here is my code:
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'product',
'posts_per_page' => $top_selling_products_nr,
'meta_key' => 'total_sales',
'paged' => $paged,
'orderby' => 'meta_value_num'
);
<?php if ( $woo_home_query->have_posts() ) : ?>
<div class="products container grid-wrapper clear">
<div class="row">
<?php
while ( $woo_home_query->have_posts() ) : $woo_home_query->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
?>
</div>
<?php if ( $woo_home_query->max_num_pages > 1 ) : ?>
<nav class="navigation is posts-navigation" role="navigation">
<h2 class="screen-reader-text"><?php esc_html_e( 'Posts navigation', 'goodz' ); ?></h2>
<div id="infinite-handle" class="nav-links">
<div class="nav-previous"><?php next_posts_link( esc_html__( 'Load More', 'goodz' ), $woo_home_query->max_num_pages ); ?></div>
</div> <!-- .nav-links -->
</nav> <!-- .navigation -->
<?php endif; ?>
</div>
<?php endif; ?>