WordPress.org

Codex

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

Function Reference/previous posts link

Description

Prints a link to the previous set of posts within the current query.

If you need the values for use in PHP, use get_previous_posts_link().

Because post queries are usually sorted in reverse chronological order, next_posts_link() usually points to older entries (toward the end of the set) and previous_posts_link() usually points to newer entries (toward the beginning of the set).

Usage

 <?php previous_posts_link$label ); ?> 

Parameters

$label
(string) (optional) The link text.
Default: '« Previous Page'

Examples

Default Usage

<?php previous_posts_link(); ?>

Working example

<?php previous_posts_link( '« Newer Entries' ); ?>

Check if previous link exists

<?php if( get_previous_posts_link() ) :

previous_posts_link( '« Newer Entries' );

endif; ?>

Notes

  • This function does not work with static pages.

Resources

Change Log

Since: 0.71

Source File

previous_posts_link() is located in wp-includes/link-template.php.

Related

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