get_meta_sql хук-фильтрWP 3.1.0

Filters the meta query's generated SQL.

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

add_filter( 'get_meta_sql', 'wp_kama_get_meta_sql_filter', 10, 6 );

/**
 * Function for `get_meta_sql` filter-hook.
 * 
 * @param string[] $sql               Array containing the query's JOIN and WHERE clauses.
 * @param array    $queries           Array of meta queries.
 * @param string   $type              Type of meta. Possible values include but are not limited to 'post', 'comment', 'blog', 'term', and 'user'.
 * @param string   $primary_table     Primary table.
 * @param string   $primary_id_column Primary column ID.
 * @param object   $context           The main query object that corresponds to the type, for example a `WP_Query`, `WP_User_Query`, or `WP_Site_Query`.
 *
 * @return string[]
 */
function wp_kama_get_meta_sql_filter( $sql, $queries, $type, $primary_table, $primary_id_column, $context ){

	// filter...
	return $sql;
}
$sql(string[])
Array containing the query's JOIN and WHERE clauses.
$queries(массив)
Array of meta queries.
$type(строка)
Type of meta. Possible values include but are not limited to 'post', 'comment', 'blog', 'term', and 'user'.
$primary_table(строка)
Primary table.
$primary_id_column(строка)
Primary column ID.
$context(объект)
The main query object that corresponds to the type, for example a WP_Query, WP_User_Query, or WP_Site_Query.

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

С версии 3.1.0 Введена.

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

WP_Meta_Query::get_sql()
get_meta_sql
wp-includes/class-wp-meta-query.php 394
return apply_filters_ref_array( 'get_meta_sql', array( $sql, $this->queries, $type, $primary_table, $primary_id_column, $context ) );

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

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