HUSKY - Product Filter for WooCommerce

woof_before_term_name

在HTML类型中使用:radio、checkbox、select、mselect,可在其标签前打印任意符号或图标。

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

 

参数

$term (string) — the term name, $taxonomy_info (array) — taxonomy data

源文件

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) && $taxonomy_info->taxonomy === 'product_cat') {
        $icon = '📁 ';
    }
    return $icon . $term;
}, 10, 2);

使用说明

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