3. WordPress Next and Previous Links for Single Pages

On a single page (which uses your single.php template) “the loop” gets a single post, so you can’t use a pagination plugin like we just did. After a post on your “single.php” by default WordPress shows a linked title to your previous and next posts (if there is one). I try to spruce this up just a little to users understand what these links really are with code like this:


<div class="navigation">
 <div class="alignleft"><?php previous_post_link('&laquo; Post before this: %link') ?><br /></div>
 <div class="alignright"><?php next_post_link('%link &raquo; Post After This') ?></div>
 <div style="clear:both;"></div>
</div>

Basically all I did here was add some bolded text before and after the links. Maybe you can think of something a little more poignant for your links – or style them better than my example here. Go to the next hack below…