[wp-hackers] Bug or Expected behaviour? Taxonomy/Term parameters

Robert Lusby nanogwp at gmail.com
Fri Jan 6 15:51:11 UTC 2012


If performing a custom WP_Query in 3.3.1, and selecting posts in a custom taxonomy by term ID - it returns posts assigned to the ID *AND* posts assigned to any child terms of this ID.

Surely if selecting by term ID it should return only posts assigned to that term, not children also.

If this is a feature rather than a bug - how do you select posts only assigned to the parent term, and not children?

<?php

$args = array(
	'tax_query' =>  array(
		array(
			'taxonomy' =>  'example',
			'field' =>  'id',
			'terms' =>  '5'
		)
	)
);
$query = new WP_Query( $args );

?>

$query will contain posts assigned to taxonomy ID5, AND posts assigned to any children terms of this ID.

Thanks,
Robert




More information about the wp-hackers mailing list