posts_clauses_request filter-hookWP 3.1.0

Filters all query clauses at once, for convenience.

For use by caching plugins.

Covers the WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT, fields (SELECT), and LIMIT clauses.

Usage

add_filter( 'posts_clauses_request', 'wp_kama_posts_clauses_request_filter', 10, 2 );

/**
 * Function for `posts_clauses_request` filter-hook.
 * 
 * @param string[] $clauses Associative array of the clauses for the query.
 * @param WP_Query $query   The WP_Query instance (passed by reference).
 *
 * @return string[]
 */
function wp_kama_posts_clauses_request_filter( $clauses, $query ){

	// filter...
	return $clauses;
}
$clauses(string[])

Associative array of the clauses for the query.

  • where(string)
    The WHERE clause of the query.

  • groupby(string)
    The GROUP BY clause of the query.

  • join(string)
    The JOIN clause of the query.

  • orderby(string)
    The ORDER BY clause of the query.

  • distinct(string)
    The DISTINCT clause of the query.

  • fields(string)
    The SELECT clause of the query.

  • limits(string)
    The LIMIT clause of the query.
$query(WP_Query)
The WP_Query instance (passed by reference).

Changelog

Since 3.1.0 Introduced.

Where the hook is called

WP_Query::get_posts()
posts_clauses_request
wp-includes/class-wp-query.php 2993
$clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) );

Where the hook is used in WordPress

Usage not found.