get_next_post( bool $in_same_term = false, int[]|string $excluded_terms = '', string $taxonomy = 'category' ): WP_Post|null|string
- Since
- 1.5.0
- Source
wp-includes/link-template.php:1806
Retrieves the next post that is adjacent to the current post.
Parameters
$in_same_termbooloptional- Whether post should be in the same taxonomy term. Default false.Default:
false $excluded_termsint[]|stringoptional- Array or comma-separated list of excluded term IDs. Default empty.Default:
'' $taxonomystringoptional- Taxonomy, if
$in_same_termis true. Default 'category'.Default:'category'
Return
WP_Post|null|string- Post object if successful. Null if global
$postis not set. Empty string if no corresponding post exists.
Uses · 1
- get_adjacent_post()Retrieves the adjacent post.
Used by · 2
- next_post()Prints link to the next post.
- twentytwenty_body_classes()Adds conditional body classes.
Source
function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy );}History
Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/link-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.