apply_filters( "get_{$adjacent}_post_sort", string $order_by, WP_Post $post, string $order )
- Since
- 2.5.0, 4.4.0, 4.9.0, 6.9.0
Filters the ORDER BY clause in the SQL for an adjacent post query.
Description
The dynamic portion of the hook name, $adjacent, refers to the type of adjacency, 'next' or 'previous'.
Possible hook names include:
get_next_post_sortget_previous_post_sort
Compatibility
- WordPress
- since 6.9.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$order_bystring- The
ORDER BYclause in the SQL. $postWP_Post- WP_Post object.
$orderstring- Sort order. 'DESC' for previous post, 'ASC' for next.
Where this hook fires · 1
wp-includes/link-template.php:2012get_adjacent_post()
Changelog
Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.9.0
Adds ID sort to ensure deterministic ordering for posts with identical dates.from the docblock
4.9.0
Added the
$order parameter.from the docblock4.4.0
Added the
$post parameter.from the docblock2.5.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.