你可以这样做
<h3>
Portfólio
</h3>
<?php
$catprod = get_terms( array(
\'taxonomy\' => \'categoria-produto\',
\'order\' => \'DESC\',
\'parent\' =>0,
\'hide_empty\' => false,
)); // Todas as categorias
?>
<div class="panel-group">
<div class="panel-heading">
<?php foreach( $catprod as $cat ): ?>
<h3 class="panel-title">
<a data-toggle="collapse" href="#<?php echo $cat->slug ?>" class="accordion-toggle" data-parent="#accordion">
<?php echo $cat->name ?>
</a>
</h3>
<?php
$args = array(
\'post_type\' => \'produto\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'categoria-produto\',
\'terms\' => $cat->slug,
\'field\' => \'slug\',
\'include_children\' => true,
\'operator\' => \'IN\'
)
),
);
$prodtype = new WP_Query($args);
?>
<div id="<?php echo $cat->slug ?>" class="panel-collapse collapse in">
<div class="panel-body">
<?php while( $query->have_posts() ):$query->the_post(); ?>
<li>
<a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>