HUSKY - Product Filter for WooCommerce

Jak wyświetlić opisy atrybutów obok terminów filtrów WooCommerce

Aby wyświetlić bardzo krótki tekst opisu obok terminów taksonomii, użyj jego pola tekstowego ‘description‘:

a następnie kod w pliku functions.php bieżącego motywu WordPress:

add_filter('woof_before_term_name', function ($term, $taxonomy_info) {
    $description = substr(strip_tags(term_description($term['term_id'])), 20);

    if (!empty($description)) {
        //instead of inline CSS you can use CSS classes
        return $term['name'] . ' <em style="float: right; font-size: 12px;display:inline-block;margin: 4px 0 0 6px;">[' . $description . ']</em>';
    }

    return $term['name'];
}, 10, 2);

Wyniki: