WP_Date_Query::get_sql_clauses() WordPress Method
The WP_Date_Query::get_sql_clauses() method is used to return the SQL clauses for a given date query. This is useful for customizing how dates are queried in WordPress.
WP_Date_Query::get_sql_clauses() #
Generate SQL clauses to be appended to a main query.
Description
Called by the public WP_Date_Query::get_sql(), this method is abstracted out to maintain parity with the other Query classes.
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.
Source
File: wp-includes/class-wp-date-query.php
protected function get_sql_clauses() {
$sql = $this->get_sql_for_query( $this->queries );
if ( ! empty( $sql['where'] ) ) {
$sql['where'] = ' AND ' . $sql['where'];
}
return $sql;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.1.0 | Introduced. |