WP_Tax_Query::__construct( array $tax_query )
Constructor.
Parameters
-
$tax_query
array Required -
Array of taxonomy query clauses.
relation
stringOptional. The MySQL keyword used to join the clauses of the query. Accepts'AND'
, or'OR'
. Default'AND'
....$0
arrayAn array of first-order clause parameters, or another fully-formed tax query.taxonomy
stringTaxonomy being queried. Optional when field=term_taxonomy_id.terms
string|int|arrayTerm or terms to filter by.field
stringField to match $terms against. Accepts'term_id'
,'slug'
,'name'
, or'term_taxonomy_id'
. Default:'term_id'
.operator
stringMySQL operator to be used with $terms in the WHERE clause.
Accepts'AND'
,'IN'
, 'NOT IN','EXISTS'
, 'NOT EXISTS'.
Default:'IN'
.include_children
boolOptional. Whether to include child terms.
Requires a $taxonomy. Default: true.
Source
File:
wp-includes/class-wp-tax-query.php
. View all referencespublic function __construct( $tax_query ) { if ( isset( $tax_query['relation'] ) ) { $this->relation = $this->sanitize_relation( $tax_query['relation'] ); } else { $this->relation = 'AND'; } $this->queries = $this->sanitize_query( $tax_query ); }
Changelog
Changelog Version Description 4.1.0 Added support for $operator
'NOT EXISTS' and'EXISTS'
values.3.1.0 Introduced.
User Contributed Notes