VIP-Coding-Standards icon indicating copy to clipboard operation
VIP-Coding-Standards copied to clipboard

Flag missing `include_children = false` on tax queries

Open david-binda opened this issue 8 years ago • 3 comments

david-binda avatar Dec 01 '17 10:12 david-binda

Please provide some more context here, such as example code that should be reported, and example code that shouldn't.

GaryJones avatar Oct 18 '18 11:10 GaryJones

See https://vip.wordpress.com/documentation/term-queries-should-consider-include_children-false/

Example code:

$args = array(
	'post_type' => 'post',
	'tax_query' => array(
		array(
			'taxonomy' => 'people',
			'field'    => 'slug',
			'terms'    => 'bob',
		),
	),
);
$query = new WP_Query( $args );

rebeccahum avatar Oct 24 '18 18:10 rebeccahum

I think we already have some query-related Sniffs, or maybe WPCS has.

GaryJones avatar Oct 25 '18 07:10 GaryJones