So I created some custom pagination for my single.php
template to show next/previous posts at the bottom. However, the way it is working currently is linear(ie on the most recent post there is only a “next post” link and on the oldest post there is only a “previous” post link).
What I would like to do is make the loop continuous, so that on the first post, the “next post” link will be to the second newest post and the “previous post” link will be the oldest post.
Here’s my pagination code:
<?php
$nextPost = get_next_post();
if($nextPost) {
$nextPostID = $nextPost->ID;
?>
<a class="prev-post" href="https://wordpress.stackexchange.com/questions/270728/<?php echo get_permalink( $nextPostID ); ?>">
<?php pagination_next($nextPostID); ?>
</a>
<?php } ?>
<?php
$prevPost = get_previous_post();
if($prevPost) {
$prevPostID = $prevPost->ID;
?>
<a class="next-post" href="<?php echo get_permalink( $prevPostID ); ?>">
<?php pagination_prev($prevPostID); ?>
</a>
<?php } ?>