On this page
WP_Tax_Query::__construct( array $tax_query )
Constructor.
Parameters
$tax_queryarray Required-
Array of taxonomy query clauses.
relationstringOptional. The MySQL keyword used to join the clauses of the query. Accepts'AND', or'OR'. Default'AND'....$0arrayAn array of first-order clause parameters, or another fully-formed tax query.taxonomystringTaxonomy being queried. Optional when field=term_taxonomy_id.termsstring|int|arrayTerm or terms to filter by.fieldstringField to match $terms against. Accepts'term_id','slug','name', or'term_taxonomy_id'. Default:'term_id'.operatorstringMySQL operator to be used with $terms in the WHERE clause.
Accepts'AND','IN', 'NOT IN','EXISTS', 'NOT EXISTS'.
Default:'IN'.include_childrenboolOptional. 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 ); }Related
Uses
Uses Description WP_Tax_Query::sanitize_relation() wp-includes/class-wp-tax-query.php Sanitizes a ‘relation’ operator.
WP_Tax_Query::sanitize_query() wp-includes/class-wp-tax-query.php Ensures the ‘tax_query’ argument passed to the class constructor is well-formed.
Used By
Used By Description WP_Query::parse_tax_query() wp-includes/class-wp-query.php Parses various taxonomy related query vars.
get_tax_sql() wp-includes/taxonomy.php Given a taxonomy query, generates SQL to be appended to a main query.
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_tax_query/__construct