WP_Tax_Query::get_sql() WordPress Method

The WP_Tax_Query::get_sql() method is used to generate the SQL statement for a given tax query. The method accepts an array of tax query arguments and returns a string containing the SQL statement.

WP_Tax_Query::get_sql( string $primary_table, string $primary_id_column ) #

Generates SQL clauses to be appended to a main query.


Parameters

$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.


Top ↑

Return

(string[]) Array containing JOIN and WHERE SQL clauses to append to the main query.

  • 'join'
    (string) SQL fragment to append to the main JOIN clause.
  • 'where'
    (string) SQL fragment to append to the main WHERE clause.


Top ↑

Source

File: wp-includes/class-wp-tax-query.php

	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();
	}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.