WP_Date_Query Generator

Overview

Use this tool to create custom code for WordPress Date Query with WP_Date_Query class.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The variable used in the code.
The MySQL keyword used to join the clauses of the query.
Operator used for comparing the value.
Textual date/time description.
Select from your saved Date Query snippets.
Comparing column other than the one in the top-level column.
Textual date/time description.
Include results from dates specified, or not.
Operator used for comparing the value.
Textual date/time description.
Select from your saved Date Query snippets.
Comparing column other than the one in the top-level column.
Textual date/time description.
Include results from dates specified, or not.
Operator used for comparing the value.
Textual date/time description.
Select from your saved Date Query snippets.
Comparing column other than the one in the top-level column.
Textual date/time description.
Include results from dates specified, or not.
Operator used for comparing the value.
Textual date/time description.
Select from your saved Date Query snippets.
Comparing column other than the one in the top-level column.
Textual date/time description.
Include results from dates specified, or not.
Operator used for comparing the value.
Textual date/time description.
Select from your saved Date Query snippets.
Comparing column other than the one in the top-level column.
Textual date/time description.
Include results from dates specified, or not.
  Save Snippet
$date_query = array(
	array(
		'before' => array(
			'year'  => 2020,
			'month' => 12,
			'day'   => 1,
		),
		'after' => array(
			'year'  => 2017,
			'month' => 1,
			'day'   => 1,
		),
		'inclusive' => false,
	),
);