HUSKY - Products Filter Professional for WooCommerce

woof_before_term_name

woof_before_term_name

允许在HTML类型(如:radio, checkbox, select, mselect)的分类术语名称前输出任意符号或图标。

参数

$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 文件或自定义插件中。
  • 此钩子在过滤过程中应用 — 更改会立即生效。
  • 始终从回调函数返回预期值类型。