previous_posts_link( string $label = null )

Displays the previous posts page link.


$label string Optional
Previous page link text.

Default: null

Top ↑

More Information

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).

Top ↑


File: wp-includes/link-template.php. View all references

function previous_posts_link( $label = null ) {
	echo get_previous_posts_link( $label );

Top ↑


Version Description
0.71 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 3 content
    Contributed by Code Amp

    A warning when using with custom queries

    This function previous_posts_link() has a condition to run if is_single() is false.

    This is good to know when creating custom queries and adding pagination using this function because where you place your custom query can change whether the pagination shows or not.

    What’s interesting is that:
    is_single() doesn’t work on pages (or media)
    is_single() does work on CPTs and posts

    So custom queries with this pagination placed on a single page will work fine, but add the same custom query + pagination to a single CPT or post, and it will not show.

You must log in before being able to contribute a note or feedback.