SOLVED
我在另一篇帖子中找到了答案
@Gustav 对于任何像您这样寻找解决方案的人,都可以访问链接或查看下面的代码,它工作得非常好。
https://wordpress.stackexchange.com/questions/123059/list-post-from-current-taxonomy-childrenTHE WORKING CODE
<?php
$term_slug = get_query_var( \'term\' );
$taxonomyName = get_query_var( \'taxonomy\' );
$current_term = get_term_by( \'slug\', $term_slug, $taxonomyName );
$termchildren = get_term_children( $current_term->term_id, $taxonomyName );
foreach ($termchildren as $child) {
$term = get_term_by( \'id\', $child, $taxonomyName );
$wpq = array (
\'taxonomy\'=>$taxonomyName,
\'term\'=>$term->slug,
\'order\'=>\'asc\',
\'orderby\'=>\'title\');
$query = new WP_Query ($wpq);
$taxonomy_img = get_term_meta( $term->term_id, \'tax-image\', true );
//echo "$term->name:<br />";
?>
<div class="row infor-row">
<div class="container">
<?php echo \'<h3 class="child-term">\'.$term->name.\'</h3>\'; ?>
<div class="col-sm-12 menu-list">
<?php if ($query->have_posts() ) : ?>
<?php while ($query->have_posts() ) : $query->the_post(); ?>
<div class="col-sm-12 price-row col-md-6 clearfix">
<div class="item-price"><?php if ($price = get_post_meta($post->ID,\'_marvilmedia_price\',true)): ?><?php echo \'$\'.$price; ?><?php endif; ?></div>
<div class="item-info">
<span><?php the_title(); ?></span><br/>
<?php $terms_as_text = get_the_term_list( $post->ID,\'menu_side\', \'\', \', \'); if (!empty($terms_as_text)) echo \'\', strip_tags($terms_as_text) ,\'\'; ?>
</div>
</div>
<?php endwhile; ?>
<!--/table-->
</div>
</div>
</div>
<div class="row free-row" style="background-image: url(\'<?php echo $taxonomy_img; ?>\');">
</div>
<?php else :
echo \'<h2>No Menu Item for \'.$term->name.\'</h2>\'; ?>
<?php endif;?>
<?php wp_reset_query(); ?>
<?php
echo "";
}
?>