Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Date query – Nested queries

Complex date query with nested date queries.

$date_query = array(
	'relation' => 'OR',
	array(
		'relation' => 'OR',
		array(
			'before' => array(
				'month' => 2,
			),
			'after' => array(
				'month' => 1,
			),
			'inclusive' => true,
		),
		array(
			'after'         => '2 months ago',
		),
	),
	array(
		'relation' => 'AND',
		array(
			'after'         => '1 year ago',
		),
		array(
			'dayofweek'     => 1,
			'compare'       => '!=',
		),
	),
);