WPDev.one
Core Function
View Source on Trac ↗

get_adjacent_post()

get_adjacent_post( mixed $in_same_term = false, mixed $excluded_terms = '', mixed $previous = true, mixed $taxonomy = 'category' )

Retrieves the adjacent post.

Parameters 3 required

Name / Type Description
bool

$in_same_term Optional. Whether post should be in the same taxonomy term. Default false.

Required
mixed

(int[] | string) $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty string.

Required
bool

$previous Optional. Whether to retrieve previous post. Default true.

Required
$taxonomy
string

Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.

Return Value

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

Function Information

Since Version
2.5.0
Source File
wp-includes/link-template.php
Advertisement