args icon indicating copy to clipboard operation
args copied to clipboard

MetaQuery Clauses can contain subclauses

Open x2764tech opened this issue 6 months ago • 1 comments

According to the docs, metaquery clauses can be nested.

The example given is (I've reformatted it for readability):

$args = [
	'post_type' => 'product',
	'meta_query' => [
		'relation' => 'OR',
		[
			'key' => 'color',
			'value' => 'orange',
			'compare' => '=',
		],
		[
			'relation' => 'AND',
			[
				'key' => 'color',
				'value' => 'red',
				'compare' => '=',
			],
			[
				'key' => 'size',
				'value' => 'small',
				'compare' => '=',
			],
		],
	],
];
$query = new WP_Query( $args );

Can I do this with Args, or is there any plan to support this?

x2764tech avatar Jun 23 '25 10:06 x2764tech

Thanks for the report. This isn't supported by Args, but that's an omission and not intentional. Nesting queries should be doable.

johnbillion avatar Jun 23 '25 21:06 johnbillion