get_previous_posts_link()
Retrieves the previous posts page link.
Hooks from the function
Return
String|null
. HTML-formatted previous page link.
Usage
get_previous_posts_link( $label );
- $label(string)
- Previous page link text.
Default: null
Examples
#1 Let's write the link to the previous posts into a variable and display it
$prev = get_previous_posts_link(); echo $prev;
#2 Removing Trailing Slashes from Prev & Next links
If you are using no-end-trailing slashes for your URLs. You may add following filter in your functions file to remove trailing slashes from generated links from get_previous_posts_links() function.
add_filter( 'get_pagenum_link', 'user_trailingslashit' );
Notes
- Global. Int. $paged
Changelog
Since 2.7.0 | Introduced. |