在这种情况下,您需要检查何时启用过滤器并采用选定的属性分类法“pa\\U brand”:
add_action( \'woocommerce_before_shop_loop\', \'desc_before\', 75 );
function desc_before() {
if (is_filtered()) {
$brands = WC_Query::get_layered_nav_chosen_attributes() [\'pa_brand\'];
if ( isset($brands) ) {
foreach ($brands[\'terms\'] as $term ) {
$term_obj = get_term_by(\'slug\', $term, \'pa_brand\');
echo \'<div class="ka-attr-description">\'.
\'<h4>\' . $term_obj ->name . \'</h4>\'.
$term_obj->description.
\'</div>\';
}
}
}
}