On this page
next_post( string $format = '%', string $next = 'next post: ', string $title = 'yes', string $in_same_cat = 'no', int $limitnext = 1, string $excluded_categories = '' )
This function has been deprecated. Use next_post_link() instead.
Prints link to the next post.
Description
See also
Parameters
$formatstring Optional-
Default:
'%' $nextstring Optional-
Default:
'next post: ' $titlestring Optional-
Default:
'yes' $in_same_catstring Optional-
Default:
'no' $limitnextint Optional-
Default:
1 $excluded_categoriesstring Optional-
Default:
''
Source
File: wp-includes/deprecated.php. View all references
function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
_deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' );
if ( empty($in_same_cat) || 'no' == $in_same_cat )
$in_same_cat = false;
else
$in_same_cat = true;
$post = get_next_post($in_same_cat, $excluded_categories);
if ( !$post )
return;
$string = '<a href="'.get_permalink($post->ID).'">'.$next;
if ( 'yes' == $title )
$string .= apply_filters('the_title', $post->post_title, $post->ID);
$string .= '</a>';
$format = str_replace('%', $string, $format);
echo $format;
}
Hooks
- apply_filters( 'the_title',
string $post_title ,int $post_id ) -
Filters the post title.
Related
Uses
| Uses | Description |
|---|---|
| get_next_post() wp-includes/link-template.php | Retrieves the next post that is adjacent to the current post. |
| _deprecated_function() wp-includes/functions.php | Marks a function as deprecated and inform when it has been used. |
| get_permalink() wp-includes/link-template.php | Retrieves the full permalink for the current post or post ID. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Use next_post_link() |
| 0.71 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/next_post