HUSKY - Products Filter Professional for WooCommerce

woof-set-shortcode-taxonomyattr-behaviour

woof_set_shortcode_taxonomyattr_behaviour

允许修改 [woof_products] 和 [woof_products_ids_prediction] 短代码中 taxonomies 属性的行为。

参数

$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 在过滤过程中应用 — 更改会立即生效。
  • 始终从回调函数返回预期的值类型。