You can alter the posts query by using the pre_get_posts
filter, and passing the parameter category__in
.
In order to do that, put the following code in your theme’s functions.php:
add_action( 'pre_get_posts', 'get_parent_category_posts' );
function get_parent_category_posts($query){
if (is_category() && is_main_query()){
$curr_cat = get_query_var('cat');
$query->set('category__in', array($curr_cat));
}
}