WP_Tax_Query::get_sql()publicWP 3.1.0

Generates SQL clauses to be appended to a main query.

Method of the class: WP_Tax_Query{}

No Hooks.


String[]. Array containing JOIN and WHERE SQL clauses to append to the main query.


$WP_Tax_Query = new WP_Tax_Query();
$WP_Tax_Query->get_sql( $primary_table, $primary_id_column );
$primary_table(string) (required)
Database table where the object being filtered is stored (eg wp_users).
$primary_id_column(string) (required)
ID column for the filtered object in $primary_table.


Since 3.1.0 Introduced.

WP_Tax_Query::get_sql() code WP 6.1.1

public function get_sql( $primary_table, $primary_id_column ) {
	$this->primary_table     = $primary_table;
	$this->primary_id_column = $primary_id_column;

	return $this->get_sql_clauses();