Skip to content

Instantly share code, notes, and snippets.

@dospuntocero
Last active January 12, 2018 02:26
Show Gist options
  • Save dospuntocero/14889e3af231eb75c627059755052fe2 to your computer and use it in GitHub Desktop.
Save dospuntocero/14889e3af231eb75c627059755052fe2 to your computer and use it in GitHub Desktop.
get only the next and prev URL instead of full anchor. useful when you need extensive markup styling
<?php
$prev = get_permalink(get_adjacent_post(false,'',false));
$next = get_permalink(get_adjacent_post(false,'',true));
?>
<a href="<?php echo $prev; ?>">Previous Post</a>
<a href="<?php echo $next; ?>">Next Post</a>
<?php //What if there isn’t a previous or next post? ?>
<php if ($prev != get_permalink()) : ?>
<a href="<?php echo $prev; ?>">Previous Post Only Displaying If Available</a>
<?php endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment