woof_set_shortcode_taxonomyattr_behaviour
このフックは、プラグインの index.php 内の public function woof_shortcode で動作し、‘additional_taxes‘ 属性を操作します。
パラメーター
$taxonomies_string (string) — the taxonomies string from the shortcode attribute
ソースファイル
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ファイル、またはカスタムプラグインに追加してください。 - このフックはフィルタリング処理中に適用され、変更は即座に反映されます。
- コールバック関数からは常に期待される値の型を返すようにしてください。
