HUSKY - Product Filter for WooCommerce

woof_filter_taxonomies

过滤从 WordPress 检索到的产品 taxonomies 数组,允许删除或修改过滤器使用的 taxonomies。

参数

$taxonomies (array) — 由 get_object_taxonomies('product', 'objects') 返回的 taxonomy 对象数组,其中已删除“product_shipping_class”和“product_type”

源文件

index.php:1394

代码示例


add_filter('woof_filter_taxonomies', function($taxonomies) {
    // Remove a specific taxonomy from filtering
    if (isset($taxonomies['pa_color'])) {
        unset($taxonomies['pa_color']);
    }
    return $taxonomies;
});

使用说明

  • 在 get_taxonomies() 方法中调用,该方法是 static-cached 的。
  • 在过滤器运行之前,product_shipping_class 和 product_type 默认未设置。
  • 用于从过滤面板中隐藏自定义 taxonomies。