split_the_query хук-фильтрWP 3.4.0

Filters whether to split the query.

Splitting the query will cause it to fetch just the IDs of the found posts (and then individually fetch each post by ID), rather than fetching every complete row at once. One massive result vs. many small results.

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

add_filter( 'split_the_query', 'wp_kama_split_the_query_filter', 10, 4 );

/**
 * Function for `split_the_query` filter-hook.
 * 
 * @param bool     $split_the_query Whether or not to split the query.
 * @param WP_Query $query           The WP_Query instance.
 * @param string   $old_request     The complete SQL query before filtering.
 * @param string[] $clauses         Associative array of the clauses for the query.
 *
 * @return bool
 */
function wp_kama_split_the_query_filter( $split_the_query, $query, $old_request, $clauses ){

	// filter...
	return $split_the_query;
}
$split_the_query(true|false)
Whether or not to split the query.
$query(WP_Query)
The WP_Query instance.
$old_request(строка)
The complete SQL query before filtering.
$clauses(string[])

Associative array of the clauses for the query.

  • where(строка)
    The WHERE clause of the query.

  • groupby(строка)
    The GROUP BY clause of the query.

  • join(строка)
    The JOIN clause of the query.

  • orderby(строка)
    The ORDER BY clause of the query.

  • distinct(строка)
    The DISTINCT clause of the query.

  • fields(строка)
    The SELECT clause of the query.

  • limits(строка)
    The LIMIT clause of the query.

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

С версии 3.4.0 Введена.
С версии 6.6.0 Added the $old_request and $clauses parameters.

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

WP_Query::get_posts()
split_the_query
wp-includes/class-wp-query.php 3333
$split_the_query = apply_filters( 'split_the_query', $split_the_query, $this, $old_request, compact( $pieces ) );

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

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