WP_Tax_Query::__construct()
Constructor.
Method of the class: WP_Tax_Query{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WP_Tax_Query = new WP_Tax_Query(); $WP_Tax_Query->__construct( $tax_query );
- $tax_query(array) (required)
Array of taxonomy query clauses.
-
relation(string)
Optional. The MySQL keyword used to join the clauses of the query. Accepts 'AND', or 'OR'.
Default: 'AND' -
...$0(array)
An array of first-order clause parameters, or another fully-formed tax query.-
taxonomy(string)
Taxonomy being queried. Optional when field=term_taxonomy_id. -
terms(string|int|array)
Term or terms to filter by. -
field(string)
Field to match $terms against. Accepts 'term_id', 'slug', 'name', or 'term_taxonomy_id'.
Default: 'term_id' -
operator(string)
MySQL operator to be used with $terms in the WHERE clause. Accepts 'AND', 'IN', 'NOT IN', 'EXISTS', 'NOT EXISTS'.
Default: 'IN' - include_children(true|false)
Optional. Whether to include child terms. Requires a $taxonomy.
Default: true
-
-
Changelog
Since 3.1.0 | Introduced. |
Since 4.1.0 | Added support for $operator 'NOT EXISTS' and 'EXISTS' values. |
WP_Tax_Query::__construct() WP Tax Query:: construct code WP 6.5.2
public 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 ); }