get_(adjacent)_post_sort filter-hook . WP 2.5.0
Filters the ORDER BY clause in the SQL for an adjacent post query.
The dynamic portion of the hook name, $adjacent, refers to the type of adjacency, 'next' or 'previous'.
Usage
add_filter( 'get_(adjacent)_post_sort', 'filter_function_name_1958', 10, 3 ); function filter_function_name_1958( $order_by, $post, $order ){ // filter... return $order_by; }
- $order_by(string)
- The ORDER BY clause in the SQL.
- $post(WP_Post)
- WP_Post object.
- $order(string)
- Sort order. 'DESC' for previous post, 'ASC' for next.
Changelog
Since 2.5.0 | Introduced. |
Since 4.4.0 | Added the $post parameter. |
Since 4.9.0 | Added the $order parameter. |
Where the hook is called
get_(adjacent)_post_sort
wp-includes/link-template.php 1862
$sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order );