WordPress at Your Fingertips
filter is not described

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'.

Possible hook names include:

  • get_next_post_sort
  • get_previous_post_sort


add_filter( 'get_(adjacent)_post_sort', 'filter_function_name_4834', 10, 3 );
function filter_function_name_4834( $order_by, $post, $order ){
	// filter...

	return $order_by;
The ORDER BY clause in the SQL.
WP_Post object.
Sort order. 'DESC' for previous post, 'ASC' for next.


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

wp-includes/link-template.php 1953
$sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order );

Where in WP core the hook is used WordPress

Usage not found.