📄 原始资料 | 展开查看原始 JSON(bricks-render_header.json){ “name”: “bricks/render_header”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-render_header/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/render_header”, “description”: { “en”: “Filters the…
📄 原始资料 | 展开查看原始 JSON(bricks-render_header.json)
{
"name": "bricks/render_header",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-render_header/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/render_header",
"description": {
"en": "Filters the rendered HTML of the Bricks header template. This allows you to wrap the header in custom markup or modify its output before it is echoed to the page.",
"zh": "筛选 Bricks 页头模板的渲染 HTML。允许你将页头包装在自定义标记中或在将其回显到页面之前修改其输出。"
},
"parameters": [
{
"name": "header_html",
"type": "string",
"type_zh": null,
"description": {
"en": "The rendered HTML of the header.",
"zh": "已渲染的页头 HTML。"
}
}
],
"example_usage": "add_filter( 'bricks/render_header', function( $header_html ) {\n // Example: Add a notification bar before the header\n $notification = '<div class=\"notification-bar\">Welcome!</div>';\n\n\n return $notification . $header_html;\n} );"
}
前言
筛选 Bricks 页头模板的渲染 HTML。允许你将页头包装在自定义标记中或在将其回显到页面之前修改其输出。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/render_header', function( $header_html ) {
// Example: Add a notification bar before the header
$notification = 'Welcome!
';
return $notification . $header_html;
} );
参数
$header_html (string):已渲染的页头 HTML。
示例代码
筛选返回值
add_filter( 'bricks/render_header', function( $header_html ) {
// Example: Add a notification bar before the header
$notification = 'Welcome!
';
return $notification . $header_html;
} );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/render_header', function( $value, $header_html ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。