Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/previous post

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use any of these functions instead.


Used on single post/permalink pages, this tag lists the previous post in chronological order from the current post. It can work in conjuntion with the next_post() tag. This tag must be used in The Loop.

For the index, category, and archives templates, use the posts_nav_link() tag.

Replace With



 <?php previous_post('format''previous''title''in_same_cat',
limitprevexcluded_category); ?> 


Default Usage

By default, displays text "previous post:" as link along with post title.

previous post: Previous Post Title

 <?php previous_post(); ?> 

Using Text As Link, Without Post Title

Displays specified text as link, without including the post title. If excessively long post titles break your layout, you may want to use this. "« Previous" is the specified text in this example; you can put whatever you want.

« Previous

 <?php previous_post('%','&laquo; Previous''no'); ?> 

Using Specific Text

Displays previous and next post links in the format with the text before the post title not shown as a link.

Previous: Previous Post Title    |    Next: Next Post Title
<p><?php previous_post('%', 'Previous:', 'no'); ?> 
| <?php next_post('%', 'Next:', 'no'); ?></p>

Using Arrows Not Text

To display text, like arrows («), at the beginning of the previous post link and at the end of the next post link so it looks like:

« « Previous Post Title    |    Next Post Title » »
<?php previous_post('&laquo; &laquo; %', '', 'yes'); ?>
| <?php next_post('% &raquo; &raquo; ', '', 'yes'); ?>


(string) Format string for the link. '%' in string will be replaced with the link, so 'Go to %' will generate "Go to <a href=..." Defaults to '%'.
(string) Link text to display. Defaults to 'previous post: '.
(string) Indicates whether title should be used as link text. If set to 'yes', immediately follows previous (above). Options are:
  • 'yes' (Default)
  • 'no'
(string) Indicates whether the previous post link must be in the same category/categories as current. Parameter works with versions of WordPress and above. If post is listed in more than one category, it will show posts within the parent category, not the child category. Options are:
  • 'yes'
  • 'no' (Default)
(integer) Sets previous post link on numeric value of parameter (current post ID minus limitprev). Defaults to 1. Default is recommended.
(integer -or- string) Numeric category ID(s) from which the previous post should not be listed. Separate multiple categories with an 'and': '1 and 5 and 15'. There is no default. Parameter works with versions of WordPress 1.5.2 and above.


See also next_post().

See also index of Function Reference and index of Template Tags.