The previous_posts_link() WordPress PHP function displays the link to the previous posts page.
Usage
previous_posts_link('Newer Posts');
Parameters
$label
(string) – Optional. The text to display for the previous page link. Default: null.
More information
See WordPress Developer Resources: previous_posts_link
Examples
Basic usage of previous_posts_link
This example will display the default link text “« Newer Entries” for the previous posts page.
previous_posts_link( __( '« Newer Entries', 'textdomain' ) );
Custom link text
This example displays “Newer Posts” as the link text for the previous posts page.
previous_posts_link('Newer Posts');
Display previous posts link with custom CSS class
This example shows how to add a custom CSS class to the previous posts link.
previous_posts_link('<span class="custom-prev-link">Newer Posts</span>');
Check if previous posts link exists
This example checks if there is a previous posts page before displaying the link.
if (get_previous_posts_link()) { previous_posts_link('Newer Posts'); }
Display previous and next posts links together
This example shows how to display both the previous and next posts links together.
previous_posts_link('Newer Posts'); next_posts_link('Older Posts', $the_query->max_num_pages);