Lots of questions about custom post types and pagination, but as far as I can find, no-one else with this problem:
- Post type created -- check
- new query for custom archive page -- check
- page one totally loads correctly -- check
- page two shows posts it should -- check. BUT: it also still has the previous posts link.
- which point to page three, even though there are no posts to display
The problem: post navigation still shows on page two, allowing for a click to page 3 (4, 5, 6 etc) -- where there are no posts. No 404, just a blank page, as though the loop is still looping through an infinite sea of nothingness.
Code:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$loop = new WP_Query( array(
'post_type' => 'portfolio',
'posts_per_page' => 10,
'paged'=>$paged
) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<article >
/*stuff in here */
</article>
<?php endwhile; ?>
<div id="post-navigation">
<div class="nav-previous"><?php next_posts_link(__( 'Previous Projects' )) ?></div>
<div class="nav-next"><?php previous_posts_link(__( 'Next Projects' )) ?></div>
</div><!-- #post-navigation -->
Other info: I'm displaying this with archive-portfolio.php -- no blank page to muddy up permalinks.
On page 1, there's no option for next post -- so that half seems to be working, but previous just lets me go back in time forever, where there are no posts to display.
Many thanks.