I have a template with a custom wp_query. I need to add navigation links to the query. No matter what page I'm on, I can't get the next_posts_link to appear. The previous_posts_link works just fine, but the next_posts_link never shows up, even if there is a next posts page.
Here's my code:
<?php get_header(); ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="page"> <h1><?php the_title(); ?></h1> </header> <?php the_content(); ?> <?php endwhile; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'paged' => $paged, ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <!-- Loop stuff --> <?php endwhile; endif; ?> <nav> <span class="older"><?php next_posts_link( __( '← Older posts', 'starkers' ) ); ?></span> <span class="newer"><?php previous_posts_link( __( 'Newer posts →', 'starkers' ) ); ?></span> </nav> <?php wp_reset_postdata(); ?> </article> <?php get_footer(); ?>
I have tried suggestions from here: next_posts_link and previous_posts_link problem and here: WP_Query and next_posts_link to no avail. I'm sure there's something really obvious I'm missing... Could it have something to do with the fact that I'm on a page template, and it doesn't think there is a next page? But then why would it think there is a previous page?
The site is here: https://www.filedropvault.com/news-resource-center/page/5/
This has been marked as a duplicate of Next_posts_link() works only with original $wp_query but I have tried the suggestions on that post, and they don't work. So I'm looking for a different answer than those given for that post.