bricks_update_template_content
Phase 3AdvancedComplexity: 7/10
Replace template element content
Overview
Replaces, appends, or prepends content in an existing Bricks template. Accepts a hierarchical element tree that is translated to flat Bricks format. The content area is auto-detected from the template type (header templates write to the header area, footer templates to the footer area). Use this to rebuild or extend a template’s visual content.
Key Features
Three content modes
Replace all content, append after existing content, or prepend before existing content.
Auto content area detection
Automatically writes to the correct Bricks content area based on template type (header/footer/content).
Hierarchical input
Accepts the same hierarchical element tree format as bricks_add_section — the Translator handles conversion.
When to Use
When rebuilding a header or footer template with new content
When adding sections to an existing template
When updating template content after design system changes
When replacing a section within a template while preserving other parts
When adding sections to an existing template
When updating template content after design system changes
When replacing a section within a template while preserving other parts
Prerequisites
Template must exist (valid template_id)
Content should reference existing global classes and color variables from the design system
Content should reference existing global classes and color variables from the design system
When NOT to Use
When updating display conditions — use bricks_update_template_conditions instead
When creating a new template from scratch — use bricks_create_template which accepts initial content
When updating individual elements within a template — use bricks_update_element with the template ID as page_id
When creating a new template from scratch — use bricks_create_template which accepts initial content
When updating individual elements within a template — use bricks_update_element with the template ID as page_id
Parameters
4 Total Parameters2 Required2 Optional
template_idnumberREQUIREDTemplate post ID.
contentobjectREQUIREDHierarchical element tree to set as template content.
modestringoptionalHow to apply the content.
Default:
replace Values: replace, append, prependcontent_areastringoptionalOverride content area. Auto-detected from template type if omitted.
Values:
content, header, footerCode Examples
Warning: Undefined array key "example_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 10
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Replace footer template content
JSON
{
"tool": "bricks_update_template_content",
"params": {
"template_id": 34,
"mode": "replace",
"content": {
"type": "section",
"settings": { "_background": { "color": { "hex": "#0a0a0f" } } },
"children": [{
"type": "container",
"settings": { "_display": "grid", "_gridTemplateColumns": "1fr 1fr 1fr 1fr", "_gap": "30" },
"children": [
{ "type": "div", "children": [
{ "type": "logo", "settings": { "height": "32px" } },
{ "type": "text-basic", "settings": { "text": "Build websites with AI." }, "globalClasses": ["text-body"] }
]}
]
}]
}
}
}Response
{
"success": true,
"element_count": 6,
"content_area": "footer"
}Common Mistakes
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Mode "replace" removes ALL existing content before adding the new tree. If you want to add a section to existing template content, use "append" or "prepend".
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
The content area is auto-detected from the template type. Only override content_area if you specifically need to write to a different area.
Tips & Warnings
Tips & Warnings
Content area mapping: Header templates auto-write to _bricks_page_header_2, footer templates to _bricks_page_footer_2, and all other template types to _bricks_page_content_2. Overriding the content_area parameter is rarely needed.
Mode behavior: « replace » completely overwrites the template. « append » adds the new element tree after existing content. « prepend » adds it before existing content.
Return Values
Related Tools
Technical Details
Changelog
v1.0
Initial release
20250101