I cannot get the <?php next_posts_link(); ?>
working in my custom post loop on the first page (
website.com/news).
The funny thing is that <?php previous_posts_link(); ?>
does work on the second page (website.com/news/page/2/)
This is my query:
<div class="col-md-12">
<h2>News</h2>
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$the_query = new WP_Query( 'posts_per_page=6&paged=' . $paged );
?>
<div class="row">
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<div class="col-md-4">
<div class="card">
<?php the_post_thumbnail(); ?>
<div class="card-body">
<h4><a class="newslink" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
<p class="card-text">
<?php
the_excerpt(40,the_date('j F, Y','','<br>'));?>
</p>
</div>
</div>
</div>
<?php
endwhile;
?>
<?php next_posts_link(); ?>
<?php previous_posts_link(); ?>
<?php wp_reset_query(); ?>
</div>
As far as I am concerned i'm using the global var $wp_query
so I'm not sure why it isnt working for the first page.