How to filter query to display posts from parent category only?

I was finally able to get this to work using the filter provided by the plugin. The query uses [cat] to get the category which doesn’t support the include_children parameter. Therefore, I had to define the tax_query argument before unsetting [cat].

Here’s the function:

add_filter( 'miniloops_query' , 'miniloops_child_posts_filter' );
function miniloops_child_posts_filter( $query ) {
$query['tax_query'] = array( array(
  'taxonomy' => 'category',
  'field'    => 'term_id',
  'terms'    => $query['cat'],
  'include_children' => 0,
),);
unset($query['cat']);
return $query;
}