在WooCommerce中,我希望在标签旁边显示所选属性的名称.
<th class="label">
<label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label>
<?php
$brand_terms = get_the_terms($post, 'pa_spieki');
$brand_string = ''; // Reset string
foreach ($brand_terms as $term) :
$brand_string .= $term->name . ' ';
endforeach;
echo $brand_string;
?>
</th>
不幸的是,我的代码返回整个列表,而不仅仅是选定的属性.
我怎样才能改变这一点?