Displays the previous post link that is adjacent to the current post.
$formatstringoptional
Default:'« %link'
$linkstringoptional
'%title'.Default:'%title'
$in_same_termbooloptional
Default:false
$excluded_termsint[]|stringoptional
Default:''
$taxonomystringoptional
$in_same_term is true. Default 'category'.Default:'category'
Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the current post. This tag must be used in The Loop.
$format is the format string for the link. This is where to control what comes before and after the link. '%link' in string will be replaced with whatever is declared as 'link' (see next parameter). 'Go to %link' will generate “Go to <a href=…” Put HTML tags here to style the final results.
function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy );
}
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/previous_post_link