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: <ul> <li>get_next_post_sort</li> <li>get_previous_post_sort</li> </ul>
Parameters
$order_bystring
The ORDER BY clause in the SQL.
$postWP_Post
WP_Post object.
$orderstring
Sort order. 'DESC' for previous post, 'ASC' for next.
2006* @since 6.9.0 Adds ID sort to ensure deterministic ordering for posts with identical dates.2007*2008* @param string$order_by The `ORDER BY` clause in the SQL.2009* @param WP_Post$post WP_Post object.2010* @param string$order Sort order.'DESC'for previous post,'ASC'for next.2011*/2012$sort=apply_filters("get_{$adjacent}_post_sort","ORDER BY p.post_date $order, p.ID $order LIMIT 1",$post,$order);20132014$query="SELECT p.ID FROM $wpdb->posts AS p $join$where$sort";2015$key=md5($query);2016$last_changed=(array)wp_cache_get_last_changed('posts');2017if($in_same_term||!empty($excluded_terms)){2018$last_changed[]=wp_cache_get_last_changed('terms');
History
Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.