get_tax_sql

Given a taxonomy query, generates SQL to be appended to a main query.

Description

(array) get_tax_sql( (array) $tax_query, (string) $primary_table, (string) $primary_id_column ); 

Returns (array)

Parameters (3)

0. $tax_query (array)
A compact tax query
1. $primary_table (string)
The primary table.
2. $primary_id_column (string)
The primary id column.

Usage

  1. if ( !function_exists( 'get_tax_sql' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // A compact tax query 
  5. $tax_query = array(); 
  6.  
  7. // The primary table. 
  8. $primary_table = ''; 
  9.  
  10. // The primary id column. 
  11. $primary_id_column = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = get_tax_sql($tax_query, $primary_table, $primary_id_column); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/taxonomy.php  
  1. function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) { 
  2. $tax_query_obj = new WP_Tax_Query( $tax_query ); 
  3. return $tax_query_obj->get_sql( $primary_table, $primary_id_column );