{
  "name": "bricks/frontend/render_data",
  "kind": "filter",
  "url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-frontend-render_data/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks/frontend/render_data",
  "description": {
    "en": "The filter allows you to modify the rendered content for different areas like header, content, and footer before it’s displayed on the frontend. The filter callback receives three parameters: The following example demonstrates how to add a unique ID attribute to each heading in the generated content. In this example, a callback function is defined within the add_filter function call targeting the bricks/frontend/render_data filter. This callback function modifies every heading tag present in the content to include a unique ID attribute. This can be useful for navigation purposes, such as creating a table of contents.",
    "zh": "Bricks 1.4 引入了 bricks/inputs/validate_field 钩子，允许你在 Bricks 提交表单之前验证单个字段。"
  },
  "example_usage": "add_filter('bricks/frontend/render_data', function($content, $post, $area) {\n  // Iterate over each heading tag\n  $content = preg_replace_callback(\n    '/(<h[1-6](.*?))>(.*?)(<\\/h[1-6]>)/i',\n    function($matches) {\n      // Add 'id' attribute if it doesn't exist\n      if (strpos($matches[2], 'id=') === false) {\n        // Use heading's content as the ID\n        $matches[0] = $matches[1] . ' id=\"' . sanitize_title($matches[3])\n        . '\">' . $matches[3] . $matches[4];\n      }\n\n\n      // Return the (potentially) modified heading tag\n      return $matches[0];\n    },\n    $content // Content to modify\n  );\n\n\n  // Return modified content\n  return $content;\n}, 10, 3);"
}