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?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.