WP query to get posts from category ( not child of it )

I have this $args for WP_Query:

$args = array(
        'post_type' => 'estructura',
        'tax_query' => array(
            array(
                'taxonomy' => 'category',
                'field'    => 'term_id',
                'terms'    => '12',
            ),
        )
    );

Witch returns the posts tagged with the category 12 or tagged with the childs categories ( of 12 )

Read More

I want only the ones tagged with category 12,

How can I prevent to return the childs?

Thanks!

Related posts

Leave a Reply

2 comments

  1. I was able to solve this problem using the include_children option

    $args = array(
        'post_type' => 'estructura',
        'tax_query' => array(
            array(
                'taxonomy' => 'category',
                'field'    => 'term_id',
                'terms'    =>  $tax_id, // 12
                'include_children' => false
            )
        )
    );