我在WooCommerce中设置了多个属性,并且正在使用自定义product-attributes.php文件。
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
<hr>
<?php echo '<strong>' . wp_kses_post( $product_attribute['label'] ) . '</strong>'; ?>
<?php echo str_replace(',', ' | ', $product_attribute['value'] ); ?>
<?php endforeach; ?>
这很好,因为每种产品都显示了每个属性。但是,我该如何显示所有属性,并简单地突出显示(或添加一个类)每种产品的选定属性。
例如,pa_availability具有1月,2月,3月,4月的产品-一个产品可能只是选择了1月,2月。
在前端,我希望它显示 Jan | 二月 | 3月| 4月(即,所选月份为粗体或突出显示)