get_(adjacent)_post_sort хук-фильтр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:

Использование

add_filter( 'get_(adjacent)_post_sort', 'wp_kama_get_adjacent_post_sort_filter', 10, 3 );

/**
 * Function for `get_(adjacent)_post_sort` filter-hook.
 * 
 * @param string  $order_by The `ORDER BY` clause in the SQL.
 * @param WP_Post $post     WP_Post object.
 * @param string  $order    Sort order. 'DESC' for previous post, 'ASC' for next.
 *
 * @return string
 */
function wp_kama_get_adjacent_post_sort_filter( $order_by, $post, $order ){

	// filter...
	return $order_by;
}
$order_by(строка)
The ORDER BY clause in the SQL.
$post(WP_Post)
WP_Post object.
$order(строка)
Sort order. 'DESC' for previous post, 'ASC' for next.

Список изменений

С версии 2.5.0 Введена.
С версии 4.4.0 Added the $post parameter.
С версии 4.9.0 Added the $order parameter.

Где вызывается хук

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

Где используется хук в WordPress

Использование не найдено.