bricks_update_template_conditions

Phase 3IntermediateComplexity: 5/10
Set template display conditions with scoring

Overview

Updates the display conditions for a Bricks template. Conditions control where the template is shown on the site. Bricks uses a specificity scoring system to resolve conflicts when multiple templates match: specific IDs (score 10) beat frontpage (9), which beats archive/term (8), which beats postType (7), which beats « any » (2). This tool also allows updating template settings alongside conditions.

Key Features

Condition types
Supports "any" (entire site), "frontpage", "postType", "archiveType", "ids" (specific posts), and "terms" (taxonomy terms).
Exclusion support
Set exclude: true to negate a condition — e.g., apply everywhere EXCEPT specific pages.
Specificity scoring
Highest specificity wins when multiple templates match. IDs (10) > frontpage (9) > archive (8) > postType (7) > any (2).
Settings update
Can update template settings (e.g., header sticky behavior) alongside conditions in a single call.

When to Use

When changing where a template is displayed (e.g., making a footer apply to only blog posts)
When resolving template condition conflicts between multiple templates of the same type
When adding exclusion conditions to prevent a template from showing on specific pages
When fine-tuning template specificity after initial creation
Prerequisites
Template must exist (valid template_id)
Understanding of Bricks condition scoring system helps resolve conflicts

When NOT to Use

When updating template visual content — use bricks_update_template_content instead
When creating a new template with conditions — use bricks_create_template which accepts conditions at creation time
When deleting a template — use bricks_delete_template

Parameters

3 Total Parameters2 Required1 Optional
template_idnumberREQUIRED
Template post ID.
conditionsarrayREQUIRED
Array of condition objects. Each has: main (type), postType (array), ids (array), archiveType (string), exclude (boolean).
settingsobjectoptional
Additional template settings to update alongside conditions.

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

Apply a footer to all pages except the homepage

JSON
{
  "tool": "bricks_update_template_conditions",
  "params": {
    "template_id": 34,
    "conditions": [
      { "main": "any" },
      { "main": "frontpage", "exclude": true }
    ]
  }
}
Response
{
  "success": true,
  "conditions": [
    { "main": "any", "id": "a1b2c3" },
    { "main": "frontpage", "exclude": true, "id": "d4e5f6" }
  ],
  "scores": [2, 9]
}

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

Apply template only to specific post types

JSON
{
  "tool": "bricks_update_template_conditions",
  "params": {
    "template_id": 40,
    "conditions": [
      { "main": "postType", "postType": ["post", "mcp_tool"] }
    ]
  }
}
Response
{
  "success": true,
  "conditions": [
    { "main": "postType", "postType": ["post", "mcp_tool"], "id": "g7h8i9" }
  ],
  "scores": [7]
}

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" for clarity.

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), NOT "front_page". The MCP plugin auto-normalizes this, but always use "frontpage" for clarity.

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
If two header templates both have condition "any", the one with the higher post ID wins (last published). Use exclusion conditions or more specific conditions to avoid ambiguity.

Tips & Warnings

Tips & Warnings

Condition ID auto-generation: Each condition needs a unique id field (6-character alphanumeric). The MCP plugin generates this automatically — you do not need to provide it.

Scoring reference: IDs = 10, frontpage = 9, archive/term = 8, postType = 7, any = 2. Higher score wins when multiple templates of the same type match a page.

Exclusion pattern: To apply a template everywhere except certain pages, use two conditions: [{main: "any"}, {main: "ids", ids: [42, 55], exclude: true}].

Return Values

FieldTypeDescription
successbooleanWhether the conditions were successfully updated.
conditionsarrayThe applied conditions with auto-generated IDs.
scoresarraySpecificity scores for each condition.

Related Tools

Technical Details

Tool ID
bricks_update_template_conditions
API Endpoint
/bricks-mcp/v1/templates/{template_id}/conditions
HTTP Method
PUT
Namespace
templates
Source File
templates/templates.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101