Here is how to code the links to the “previous” and the “next” post under a WordPress post in single.php.
<?php
$prev_post = get_adjacent_post(false, '', true);
if(!empty($prev_post)) {?>
<a href="<?php echo get_permalink($prev_post->ID);?>">
<i class="fa fa-angle-left"></i> Previous posts
<?php echo $prev_post->post_title;?>
</a>
<?php }?>
<?php
$next_post = get_adjacent_post(false, '', false);
if(!empty($next_post)) {
?>
<a href="<?php echo get_permalink($next_post->ID);?>">
Next posts <i class="fa fa-angle-right"></i>
<?php echo $next_post->post_title;?>
</a>
<?php }?>
Other posts by admin