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


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|string|WP_Post: Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.

Ready to get started?

Tell us about your needs

Let us lead the way. We’ll help you select a top tier development partner. We’ll train your developers, operations, infrastructure, and editorial teams. We’ll coarchitect your deployment processes. We will provide live support for peak events. We’ll help your people avoid dark alleys and blind corners, and reduce wasted cycles.