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文件或自定义插件中。 - 该钩子在筛选过程中应用 —— 更改会立即生效。
- 始终从回调函数返回预期的值类型。
