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) — ショートコード属性からのタクソノミー文字列

ソースファイル

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` はフィルタリング処理中に適用され、変更はすぐに有効になります。
  • `callback function` からは常に期待される値の型を返してください。