How to get link and title of next and previous post on single page

Here’s what I did.

$previous = get_previous_post();
$next = get_next_post();

if ( get_next_post() ) { ?>
  <p><?php echo get_the_title($next) ?></p>
<?php } if ( get_previous_post() ) { ?>
  <p><?php echo get_the_title($previous) ?></p>
<?php } ?>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)