Skip to content

Instantly share code, notes, and snippets.

@metinsaylan
Created March 18, 2015 00:44
Show Gist options
  • Save metinsaylan/35b46fb203149cb9a1ce to your computer and use it in GitHub Desktop.
Save metinsaylan/35b46fb203149cb9a1ce to your computer and use it in GitHub Desktop.
Bootstrap pager links for WordPress single.php template
<?php
// This template can be included in your single.php template to display <Previous-Next> links below your post.
// It uses aligned pager template stated here > http://getbootstrap.com/components/#aligned-links
?>
<nav>
<ul class="pager">
<?php
$post_permalink = get_permalink();
$previous_post = get_permalink(get_adjacent_post(false,'',false));
$next_post = get_permalink(get_adjacent_post(false,'',true));
if( $post_permalink != $previous_post ):
?>
<li class="previous"><a href="<?php echo $previous_post; ?>"><span aria-hidden="true">&larr;</span> Previous</a></li>
<?php endif; ?>
<?php if( $post_permalink != $next_post ): ?>
<li class="next"><a href="<?php echo $next_post; ?>">Next <span aria-hidden="true">&rarr;</span></a></li>
<?php endif; ?>
</ul>
</nav>
<?php /* EOF */ ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment