HUSKY - Product Filter for WooCommerce

woof_set_shortcode_taxonomyattr_behaviour

This hook works in index.php 插件的 public function woof_shortcode and allows to manipulate with ‘additional_taxes‘。

参数

$taxonomies_string (string) — 来自短代码属性的 taxonomies 字符串

源文件

index.php

代码示例


add_filter('woof_set_shortcode_taxonomyattr_behaviour', function($taxonomies_string) {
    // Force specific taxonomy to always be included
    $additional = 'product_tag:featured,on_sale';
    if (!empty($taxonomies_string)) {
        $taxonomies_string .= '+' . $additional;
    } else {
        $taxonomies_string = $additional;
    }
    return $taxonomies_string;
});

使用说明

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