get_adjacent_post

SummerySummery

Retrieves the adjacent post.

Syntax

get_adjacent_post( bool $in_same_term = false, array|string $excluded_terms = '', bool $previous = true, string $taxonomy = 'category' )

DescriptionDescription

Can either be next or previous post.

ParametersParameters

$in_same_term

(bool) (Optional) Whether post should be in a same taxonomy term.

Default value: false

$excluded_terms

(array|string) (Optional) Array or comma-separated list of excluded term IDs.

Default value: ''

$previous

(bool) (Optional) Whether to retrieve previous post. Default true

Default value: true

$taxonomy

(string) (Optional) Taxonomy, if $in_same_term is true.

Default value: 'category'

ReturnReturn

(null|string|WP_Post) Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.

SourceSource

File: wp-includes/link-template.php


			

ChangelogChangelog

Changelog
Version Description
2.5.0 Introduced.
Scroll to Top