HUSKY - Product Filter for WooCommerce

woof_before_term_name

Uses in html types as: radio, checkbox, select, mselect for printing any symbols or icons before its label

wp-content\plugins\woocommerce-products-filter\views\html_types\checkbox.php

 

参数

$term (string) — 术语名称, $taxonomy_info (array) — 分类数据

源文件

views/html_types/checkbox.php, radio.php, select.php

代码示例


add_filter('woof_before_term_name', function($term, $taxonomy_info) {
    // Add a custom icon or badge before the term name
    $icon = '';
    if (isset($taxonomy_info->taxonomy) AND $taxonomy_info->taxonomy === 'product_cat') {
        $icon = '📁 ';
    }
    return $icon . $term;
}, 10, 2);

使用说明

  • 将此代码添加到您的主题的 functions.php 文件或自定义插件中。
  • 此钩子在过滤过程中应用 — 更改会立即生效。
  • 始终从回调函数返回预期值类型。