Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prosantamazumder/2a667401586344732f8aacb0ba800c3c to your computer and use it in GitHub Desktop.
Save prosantamazumder/2a667401586344732f8aacb0ba800c3c to your computer and use it in GitHub Desktop.
WordPress Get Next Post and Previous Post Link
<div class="col-sm-12">
<div class="theme-pagination">
<ul class="list-inline text-center">
<?php // if need post next previous
$prev_post = get_previous_post();
$id = $prev_post->ID ;
$permalink = get_permalink( $id );
?>
<?php
$next_post = get_next_post();
$nid = $next_post->ID ;
$permalink = get_permalink($nid);
?>
<li class="pull-left"><?php previous_post_link( '%link', __('<i class="fa fa-arrow-left" aria-hidden="true"></i>', 'mywebsite' ) ); ?>
</li>
<li class="pull-right"><?php next_post_link( '%link', __( '<i class="fa fa-arrow-right"></i>', 'mywebsite' ) ); ?>
</li>
</ul>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment