Wordpress post pagination continuous
I have these shortcodes which I am using as links in my front end to get the next post and previous post.
When I get to the last post it just keeps reloading the last post again. How can I get it to loop back to the first post?
function prev_shortcode($atts) {
$prev_post = get_previous_post();
$permalink = get_permalink($prev_post);
return ($permalink);
}
add_shortcode( 'prev', 'prev_shortcode' );
function next_shortcode($atts) {
$next_post = get_next_post();
$permalink = get_permalink($next_post);
return ($permalink);
}
add_shortcode( 'next', 'next_shortcode' );
Topic next-post-link previous-post-link shortcode pagination Wordpress
Category Web