Bricks 中文文档:bricks_body

📄 原始资料  |  展开查看原始 JSON(bricks_body.json){ “name”: “bricks_body”, “kind”: “action”, “url”: “https://academy.bricksbuilder.io/developer/hooks/actions/bricks-body/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks_body”, “description”: { “en”: “Runs in header.php after the document head clos…

📄 原始资料  |  展开查看原始 JSON(bricks_body.json)
{
  "name": "bricks_body",
  "kind": "action",
  "url": "https://academy.bricksbuilder.io/developer/hooks/actions/bricks-body/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks_body",
  "description": {
    "en": "Runs in header.php after the document head closes and before the site-wrapper and header hooks. Bricks attaches its opening <body> tag callback to this hook at priority 1 . Default-priority callbacks run after the opening body tag and after Bricks has printed body-start scripts and skip links.",
    "zh": "在 header.php 中,于文档 head 关闭之后、站点包装器与页头钩子之前触发。Bricks 在优先级 1 处将其打开 <body> 标签的回调挂载到此钩子。默认优先级的回调会在打开 body 标签之后、在 Bricks 输出 body-start 脚本与跳转链接之后运行。"
  },
  "example_usage": "add_action( 'bricks_body', function() {\n    echo '<div id=\"body-integration-root\"></div>';\n} );"
}

前言

在 header.php 中,于文档 head 关闭之后、站点包装器与页头钩子之前触发。Bricks 在优先级 1 处将其打开 标签的回调挂载到此钩子。默认优先级的回调会在打开 body 标签之后、在 Bricks 输出 body-start 脚本与跳转链接之后运行。

用法

将代码加入子主题的 functions.php

add_action( 'bricks_body', function() {
    echo '
'; } );

示例代码

官方示例用法

add_action( 'bricks_body', function() {
    echo '
'; } );

补充说明

更多细节可参考 官方文档