woof_taxonomy_type_objects_front_render
过滤分类法类型对象是否应作为当前筛选器类型渲染,并允许传递修改后的参数,支持自定义分类法渲染扩展。
参数
$is (bool) — 布尔值,指示当前对象的 html_type 是否与配置的分类法类型匹配
$html_type (string) — 正在检查的当前分类法类型扩展对象的 html_type 键
$tax_type (string) — 当前分类法配置的分类法类型(例如 'radio'、'checkbox'、'select')
$args (array) — 渲染参数数组,包括 woof_settings、taxonomies_info 和其他模板数据
源文件
views/woof.php:291
代码示例
add_filter('woof_taxonomy_type_objects_front_render', function($is, $html_type, $tax_type, $args) {
// Force a custom renderer for a specific taxonomy
if ('my_custom_tax' === $html_type) {
return array(
'is' => true,
'args' => array_merge($args, array('custom_data' => 'value'))
);
}
return $is;
}, 10, 4);
使用说明
- 当过滤器返回一个带有 'args' 键的数组时,这些参数会覆盖现有的 $args 变量以进行后续渲染。
- 当 'is' 返回 true(且未被覆盖)时,将渲染扩展的 html_type 视图。
- 如果没有分类法类型扩展匹配,则使用默认的单选视图作为备用。