WP_Date_Query::get_sql() WordPress Method

The WP_Date_Query::get_sql() method is used to generate the SQL code for retrieving posts within a specified date range. It takes two arguments: the first is an array of date parameters, and the second is the name of the database table to query. The method returns an SQL string.

WP_Date_Query::get_sql() #

Generate WHERE clause to be appended to a main query.


Return

(string) MySQL WHERE clause.


Top ↑

Source

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

	public function get_sql() {
		$sql = $this->get_sql_clauses();

		$where = $sql['where'];

		/**
		 * Filters the date query WHERE clause.
		 *
		 * @since 3.7.0
		 *
		 * @param string        $where WHERE clause of the date query.
		 * @param WP_Date_Query $query The WP_Date_Query instance.
		 */
		return apply_filters( 'get_date_sql', $where, $this );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.7.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.