📄 原始资料 | 展开查看原始 JSON(bricks-get_template_tags.json){ “name”: “bricks/get_template_tags”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-get_template_tags/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/get_template_tags”, “description”: { “e…
📄 原始资料 | 展开查看原始 JSON(bricks-get_template_tags.json)
{
"name": "bricks/get_template_tags",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-get_template_tags/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/get_template_tags",
"description": {
"en": "Filters the list of template tags displayed in the Bricks template manager. Template tags are a custom taxonomy used to organize templates.",
"zh": "在 Bricks 主查询循环结束后触发。可用于在主查询循环运行后设置/重置数据。"
},
"parameters": [
{
"name": "tags",
"type": "array",
"type_zh": null,
"description": {
"en": "Associative array of template tags, where the key is the term slug and the value is the term name.",
"zh": "模板标签的关联数组,键为术语 slug,值为术语名称。"
}
}
],
"example_usage": "add_filter( 'bricks/get_template_tags', function( $tags ) {\n // Example: Remove the 'dark' tag from the list\n if ( isset( $tags['dark'] ) ) {\n unset( $tags['dark'] );\n }\n\n\n return $tags;\n} );"
}
前言
在 Bricks 主查询循环结束后触发。可用于在主查询循环运行后设置/重置数据。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/get_template_tags', function( $tags ) {
// Example: Remove the 'dark' tag from the list
if ( isset( $tags['dark'] ) ) {
unset( $tags['dark'] );
}
return $tags;
} );
参数
$tags (array):模板标签的关联数组,键为术语 slug,值为术语名称。
示例代码
筛选返回值
add_filter( 'bricks/get_template_tags', function( $tags ) {
// Example: Remove the 'dark' tag from the list
if ( isset( $tags['dark'] ) ) {
unset( $tags['dark'] );
}
return $tags;
} );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/get_template_tags', function( $value, $tags ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。