HUSKY - Product Filter for WooCommerce

woof_set_shortcode_taxonomyattr_behaviour

このフックは次で機能します index.php プラグインの public function woof_shortcode と、‘ の操作を許可しますadditional_taxes‘.

パラメータ

$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` からは常に期待される値の型を返してください。