Constructor.
$meta_queryarrayoptional
relation string'AND' or 'OR'. Default 'AND'....$0 arraykey string|string[]compare_key string'=''!=''LIKE''IN''REGEXP''RLIKE''EXISTS' (alias of '=')'!=') Default is 'IN' when $key is an array, '=' otherwise.type_key string'BINARY' for case-sensitive regular expression comparisons. Default is ''.value string|string[]compare string'=''!=''>''>=''<''<=''LIKE''IN''BETWEEN''REGEXP''RLIKE''EXISTS''IN' when $value is an array, '=' otherwise.type string'NUMERIC''BINARY''CHAR''DATE''DATETIME''DECIMAL''SIGNED''TIME''UNSIGNED' Default is 'CHAR'.Default:false
public function __construct( $meta_query = false ) {
if ( ! $meta_query ) {
return;
}
if ( isset( $meta_query['relation'] ) && 'OR' === strtoupper( $meta_query['relation'] ) ) {
$this->relation = 'OR';
} else {
$this->relation = 'AND';
}
$this->queries = $this->sanitize_query( $meta_query );
}
| Version | Description |
|---|---|
| 5.3.0 | Increased the number of operators available to $compare_key. Introduced $type_key, which enables the $key to be cast to a new data type for comparisons. |
| 5.1.0 | Introduced $compare_key clause parameter, which enables LIKE key matches. |
| 4.2.0 | Introduced support for naming query clauses by associative array keys. |
| 3.2.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_meta_query/__construct