Documentation Functions wpcom-caching.php wpcom_vip_get_adjacent_post()

wpcom_vip_get_adjacent_post

Retrieve adjacent post.

Can either be next or previous post. The logic for excluding terms is handled within PHP, for performance benefits. Props to Elliott Stocks

Parameters

Name Type Description

bool

$in_same_term Optional. Whether post should be in a same taxonomy term. Note – only the first term will be used from wp_get_object_terms().

int

$excluded_term Optional. The term to exclude.

bool

$previous Optional. Whether to retrieve previous post.

string

$taxonomy Optional. Taxonomy, if $in_same_term is true. Default ’category’.

Return Value

null or string or WP_Post: Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.