to solve this you can create a page template, on this page template
1.get the top level categories only, set parent value to zero
$args = array(
'orderby' => 'name',
'parent' => 0
);
$categories = get_categories( $args );
2.get posts in all parent categories
foreach ( $categories as $category ) {
$all_posts=get_post('category='.$category->term_id);
foreach( $myposts as $post ){
setup_postdata($post)
echo'<li>';'
echo'<a href="'.the_permalink().'">'.the_title().'</a>';'
echo'</li>';'
}
}
3.if you not want to create page template, then
in category.php(modify it as your design requirement)
// Get children categories of current cat if they exist
if ( $excludes = get_categories( "child_of=" . $wp_query->get( 'cat' ) ) ) {
// For each child, add just the ID to an array
foreach ( $excludes as $key => $value ) {
$exs[] = $value->term_taxonomy_id;
}
}
// In Loop
if(have_post()){
while(have_posts()){
the_post();
//get all category of current post
$categories = get_the_category();
foreach($categories as $category) {
//check if any category is child category of current category
if( in_array($category,$exs) )
continue;
}
the_title();
}
}