What you are doing
你的
foreach 嵌套在内部
while (have_posts()) : the_post();. 这个while循环,循环浏览你的每一篇帖子(属于“hip\\u hop”类型)。
因此,对于“hip\\u-hop”类型中的每一篇帖子,您可以找到该帖子的分类术语“sub\\u”类型(这是$cam_brands). 然后,对于每个相关术语(在$cam_brands) 您获得了与该术语相关的所有帖子(或$brand). 
你的决赛foreach 循环浏览每个帖子并显示它们。
What I think you are trying to do
我不知道WordPress是否有任何本地的、直接的方式可以将某个分类术语的所有帖子“拆分”到它的子项中。但下面的方法可以做到这一点(尽管不是特别有效)。
此外,“sub\\u流派”似乎是与“流派”不同的分类法,对吗?如果你想要一种亲子关系,你应该简单地把“流派”变成hierarchal taxonomy, 并以创建“子类别”的相同方式创建子类别。一旦你做到了这一点,以下应该与以下注意事项一起使用。
$term = get_queried_object();
//Get all children of this term;
$children = get_terms( \'genre\', 
    array(
        \'parent\'=>$term->term_id;
    ) ) ;
if($children):
    //We have an array of child (of current genre) terms. Loop through and display the posts
    foreach($children as $child):
        echo \'<h2>\'.$child->slug.\'</h2>\';
        // The Query - get all posts for this child-genre.
        $args = array(\'post_type\' => \'track\', \'taxonomy\' => \'genre\', \'term\' => $child->slug, \'post_status\' => \'publish\',\'posts_per_page\' => -1);
        $child_posts = new WP_Query ($args);
        // The Loop - display all posts for this child-genre.
        while ( $child_posts->have_posts() ) : $child_posts->the_post();
            echo \'<li>\';
                the_title();
            echo \'</li>\';
        endwhile;
        // Reset Post Data
        wp_reset_postdata();
    endforeach;
else:
    //On genre with no children - you may want to do something else.
    echo \'No sub-genre for this genre found\';
endif;
Caveats
- 此代码未经测试:D(但应该有效)
- 它依赖于您的流派/子流派,所有这些都是一个层次的一部分,访问没有子流派的流派将显示“无子流派”消息将不显示与流派术语关联但没有任何子项的曲目