I have kept a Prev-Next option in the single post page to navigate though the posts and this is what I’m using for the next button.
<?php echo get_permalink(get_adjacent_post(false,'',false)); ?>
But I can’t figure out a way to link this same button to the very first posts when there are no more new posts to show. The reason is that the posts are used to show products.
Please note: To link Prev button in oldest post to the newest post I have used used this code.
<?php $next_page=get_permalink(get_adjacent_post(false,'',true));
$current_page=get_permalink();
if($next_page==$current_page){
$args = array( 'numberposts' => '1', 'category' => CAT_ID );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo get_permalink($recent["ID"]);
}
} else {
echo $next_page;
}
?>
add the args to query whatever posts are part of the products.
$args should be something like this (make sure it returns all the products posts):