WordPress next / previous post links

I just added some next / previous post links to this blog. It was really easy to do it, and I think it is a very nice improvement. All of the functions are already built into WordPress, it was just a matter of finding them.

Here’s the PHP code to place where you want the links to show up:

<?php if($single) { ?>
<div class="nextprev">
<span class="prev"><?php previous_post('&lsaquo; %', '', 'yes', 'no'); ?></span>
<span class="next"><?php next_post('% &rsaquo;', '', 'yes', 'no'); ?></span>
<?php } ?>

And here’s the CSS I added to my stylesheet to get them to sit where I wanted them:

.nextprev {
    height: 1.5em;
.nextprev .prev {
    float: left;
.nextprev .next {
    float: right;

I’m not entirely sure they will stay. I might replace them with something different, like a “more posts in this category” or a “related posts” type setup. I like the idea of flipping through a blog in a linear fashion, and I think it suits this blog quite well since all the content is generally about interesting internet happenings or loosely related technical offerings.

Either way, it’s pretty simple to add them to your own blog, so enjoy!

One thought on “WordPress next / previous post links

Comments are closed.