[wp-hackers] Bug or Expected behaviour? Taxonomy/Term parameters
otto at ottodestruct.com
Fri Jan 6 17:10:41 UTC 2012
Add 'include_children'=>false to your tax query array if you don't
want the children.
On Fri, Jan 6, 2012 at 9:51 AM, Robert Lusby <nanogwp at gmail.com> wrote:
> 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?
> $args = array(
> 'tax_query' => 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.
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers