前言
此筛选器允许你修改 Bricks 在查询筛选索引器中使用的 meta_query。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/filter/taxonomy_args', function( $args, $element ) {
// Example: Exclude specific term IDs from the filter options
$args['exclude'] = [ 1, 2, 3 ];
return $args;
}, 10, 2 );
参数
$args(array):传递给 get_terms() 的参数数组。$element(object):筛选元素实例。
示例代码
筛选返回值
add_filter( 'bricks/filter/taxonomy_args', function( $args, $element ) {
// Example: Exclude specific term IDs from the filter options
$args['exclude'] = [ 1, 2, 3 ];
return $args;
}, 10, 2 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/filter/taxonomy_args', function( $value, $args ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。