next_posts_link not working in custom loop

I’ve created a custom loop for posts, that works with Bootstrap, in which, I’ve added pagination – however it doesn’t seem to be working. It just shows an empty button…

<?php $args = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => 1
);

$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
$i = 0;
while ($my_query->have_posts()) : $my_query->the_post();
if($i % 2 == 0) { ?>
<div class=”row”><?php } ?>
<div class=”col-md-6″>
<div class=”overview”>
<!– Post details here –>
</div>
</div>
<?php $i++; if($i != 0 && $i % 2 == 0) { ?>
</div><!–/.row–>
<div class=”clearfix”></div>
<?php }
endwhile; ?>
<nav class=”pagination”>
<button class=”btn-whole”><?php previous_posts_link(‘Previous’) ?></button>
<button class=”btn-whole”><?php next_posts_link(‘Next’) ?></button>
</nav>
<?php } wp_reset_query(); ?>

Any ideas on why this might be happening?

Read more here:: next_posts_link not working in custom loop

Leave a Reply

Your email address will not be published. Required fields are marked *