bricks_create_template

Phase 3IntermediateComplexity: 5/10
Create a header, footer, section, or archive template

Overview

Creates a new Bricks template (header, footer, section, archive, popup, etc.) with optional initial content and display conditions. Templates are WordPress custom post types with type metadata that determine where they are applied. This is the primary tool for building site-wide headers, footers, archive layouts, and reusable sections.

Key Features

All template types
Supports header, footer, archive, search, error, section, popup, and 20+ WooCommerce template types.
Initial content
Optionally provide a hierarchical element tree that is translated to Bricks format on creation — build the template in a single call.
Display conditions
Set conditions at creation time: "any" (entire site), "frontpage", "postType", "archiveType", "ids" (specific pages), or "terms".
Template settings
Configure header-specific settings like sticky behavior (headerSticky, headerStickyOnScroll, headerPosition).

When to Use

When building a new header or footer template (Phase 3)
When creating archive templates for custom post types or WooCommerce
When building reusable section templates that can be applied across multiple pages
When setting up error (404) or search results templates
Prerequisites
Design system should be set up first (Phase 2) before building templates
For WooCommerce templates, WooCommerce plugin must be active
Color palette and global classes should exist for consistent template styling

When NOT to Use

When creating a regular page — use bricks_create_page instead
When creating a popup — use bricks_create_popup which has trigger/animation settings
When you need to update an existing template — use bricks_update_template_content or bricks_update_template_conditions

Parameters

6 Total Parameters2 Required4 Optional
titlestringREQUIRED
Template title (e.g., "Main Header", "Blog Archive").
typestringREQUIRED
Template type — determines where the template is applied.
Values: header, footer, archive, search, error, section, popup, wc_archive, wc_product, wc_cart, wc_cart_empty, wc_form_checkout, wc_form_pay, wc_thankyou, wc_order_receipt, wc_account_dashboard, wc_account_orders, wc_account_view_order, wc_account_downloads, wc_account_addresses, wc_account_form_edit_address, wc_account_form_edit_account, wc_account_form_login, wc_account_form_lost_password, wc_account_form_lost_password_confirmation, wc_account_reset_password
statusstringoptional
Post status for the template.
Default: publish Values: publish, draft
contentobjectoptional
Initial element tree in hierarchical format. Translated to flat Bricks format automatically.
conditionsarrayoptional
Display conditions controlling where the template applies. Each condition has: main (type), postType, ids, archiveType, exclude.
settingsobjectoptional
Template settings like headerPosition, headerSticky, headerStickyOnScroll.

Code 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

Create a sticky header template for the entire site

JSON
{
  "tool": "bricks_create_template",
  "params": {
    "title": "Main Header",
    "type": "header",
    "status": "publish",
    "conditions": [{ "main": "any" }],
    "settings": {
      "headerSticky": true,
      "headerStickyOnScroll": true
    },
    "content": {
      "type": "section",
      "children": [{
        "type": "container",
        "settings": { "_display": "flex", "_justifyContent": "space-between", "_alignItems": "center" },
        "children": [
          { "type": "logo", "settings": { "height": "40px" } },
          { "type": "nav-menu", "settings": { "menu": 5 } },
          { "type": "button", "settings": { "text": "Contact" }, "globalClasses": ["btn-primary"] }
        ]
      }]
    }
  }
}
Response
{
  "template_id": 36,
  "title": "Main Header",
  "type": "header",
  "conditions": [{ "main": "any", "id": "a1b2c3" }],
  "element_count": 5
}

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
Bricks uses "any" for the entire site condition, NOT "entireSite". The MCP plugin auto-normalizes this, but always use "any" explicitly.

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
Bricks uses "frontpage" (one word) for the front page condition, NOT "front_page". The MCP plugin auto-normalizes this, but always use "frontpage" explicitly.

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
For header templates, always set headerSticky and headerStickyOnScroll in the settings parameter. Without these, the header will scroll away.

Tips & Warnings

Tips & Warnings

Condition scoring: Bricks resolves template conflicts using specificity scores. From highest to lowest: specific IDs (10) > frontpage (9) > archive/term (8) > postType (7) > any (2). Use bricks_update_template_conditions to fine-tune conditions after creation.

Critical bug note: Each condition must have an id field (6-char random alphanumeric). The MCP plugin auto-generates this, so you do not need to provide it manually.

Content area mapping: The content area is auto-detected from template type — header templates write to _bricks_page_header_2, footer templates to _bricks_page_footer_2, and all others to _bricks_page_content_2.

Return Values

FieldTypeDescription
template_idnumberThe new template post ID.
titlestringTemplate title.
typestringTemplate type (header, footer, etc.).
conditionsarrayApplied display conditions with generated IDs.
element_countnumberNumber of elements created in the template.

Related Tools

Technical Details

Tool ID
bricks_create_template
API Endpoint
/bricks-mcp/v1/templates
HTTP Method
POST
Namespace
templates
Source File
templates/templates.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101