Display only posts from a specific parent category

$the_category_id    = 10;
$new_posts          = new WP_Query( array(
    'post_type'     => 'post',
    'post_status'   => 'publish',
    'tax_query'     => array(
        array(
            'taxonomy'          => 'category',
            'terms'             => array( $the_category_id ),
            'field'             => 'term_id',
            'operator'          => 'AND',
            'include_children'  => false
        )
    )
) );

So basically the difference is include_children parameter.

Leave a Comment