Creates or debugs Bricks templates and their placement conditions. Explains template types, condition scoring, and the one-template-wins resolution logic for Bricks theme.
Ships in bricks. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Bricks templates are WP posts of the bricks_template custom post type, tagged with a _bricks_template_type meta ('header', 'footer', 'content', etc.) and gated by display conditions. For every page the site renders, Bricks picks one template per part (header, footer, content) by scoring conditions: the highest score wins. WooCommerce adds extra template types when its integration is active. Use this as the condition-selection reference for the normal Bricks template flow.
Normal template types are registered in includes/setup.php. password_protection is a conditional template type used by password protection. Post_meta constant BRICKS_DB_TEMPLATE_TYPE = '_bricks_template_type' (functions.php).
| Value | Purpose | Eligible contexts |
|---|---|---|
header | Site header | All pages (one winner per page) |
footer | Site footer | All pages |
content | Single-post body ("Single") | is_singular(): single posts, pages, CPTs |
section | Reusable content block | Inserted via the Template element: doesn't self-render |
popup | Popup template | Rendered when conditions match + an interaction opens it |
archive | Archive layout | is_archive(), is_post_type_archive(), taxonomies, authors, dates |
search | Search results | is_search() |
error | 404 page | is_404() |
password_protection (conditional) | Password gate | When WP password-protection is active on a post |
Each template post has one type value (via the meta). section is special: it doesn't self-render; it's used by the Template element inside other templates.
For each render part (header, content, footer), Bricks iterates every template of that type, scores each template's conditions against the current request, and picks the highest-scoring template. Do not rely on same-score ties: the source stores matches by score, so a later template at the same score can replace an earlier one based on query iteration order.
Resolution logic: includes/database.php:725-808 (find_template_id()).
Templates that lose selection are skipped. When a template does not appear, check matching conditions, competing templates, page-level disable settings, and the requested render context before concluding which template won.
From includes/database.php::screen_conditions(). Higher = more specific = wins.
| Score | Condition match | Example |
|---|---|---|
| 0 | No conditions | Ultimate fallback |
| 1 | Template type matches content type | Search template on a search page |
| 2 | main: any | Entire website |
| 3 | main: archiveType with archiveType: any | Any archive page |
| 4 | Any term archive with no archiveTerms list | All taxonomy archives |
| 7 | Singular post-type match, all CPT archives with archivePostTypes omitted, or runtime taxonomy::all term-archive match | All posts of type Product |
| 8 | Child pages of specific IDs, assigned terms, specific archive CPT, author, date, search/error, or specific term archive | Archive of product_cat: deals |
| 9 | Front page | main: frontpage |
| 10 | Specific post ID via main: ids | Exactly post id 42 |
| +100 | Password-protection templates | Password protection wins over normal templates |
Implication: a template with main: any (score 2) gets beaten by a template with a post-type match (score 7 or 8) on that post type. Use any as the base fallback, then create specific templates that win on their pages.
From includes/database.php:589-625. WP context -> Bricks content_type:
| WP function | content_type |
|---|---|
is_singular() | content |
is_post_type_archive(), is_tax(), is_category(), is_tag(), is_author(), is_date() | archive |
is_search() | search |
is_404() | error |
Filterable via bricks/database/content_type (includes/database.php:619): useful for custom routing plugins.
Then find_template_id() picks a template of the matching type whose conditions score highest.
Stored in _bricks_template_settings meta, under the templateConditions key.
The MCP set-template-conditions ability accepts the conditions array at the top level:
{
"templateId": 123,
"conditions": [
{ "main": "any" },
{ "main": "frontpage" },
{ "main": "postType", "postType": ["post", "page"] },
{ "main": "archiveType", "archiveType": ["postType"], "archivePostTypes": ["product"] },
{ "main": "search" },
{ "main": "error" },
{ "main": "terms", "terms": ["category::5", "product_cat::12"] },
{ "main": "ids", "ids": [42, 89] },
{ "main": "any", "hookName": "woocommerce_after_main_content", "hookPriority": 10 }
]
}
Bricks stores that array as _bricks_template_settings.templateConditions.
The main enum is exactly: any, frontpage, postType, archiveType, search, error, terms, ids, hook. hook is accepted by the MCP validator for legacy/convenience input, but set-template-conditions stores it as any when hookName is present (includes/abilities/templates.php:1006-1014). Do not invent kinds. In particular:
any (NOT entireWebsite)terms (NOT archiveTerm)hookName is for section templates only: it injects the section's content at the named WP action.Term identifiers accepted by set-template-conditions depend on the condition key:
terms: strings in taxonomy::id form, e.g. "category::5", "product_cat::12". Do not send raw term IDs or term objects.archiveTerms: strings in taxonomy::id or taxonomy::all form, e.g. "category::5", "product_cat::all". The taxonomy::all branch is archive-only (includes/database.php:1193).Multiple conditions in the array = OR. Any single condition match wins.
Check header and footer template selection separately from the content template.
Best practice: a single header template with { "main": "any" } (score 2) as the base, then variants for specific sections if needed.
See the bricks-headers-footers skill for the meta-routing rules MCP element-write tools follow when editing header/footer template trees.
To create a CPT archive layout:
archive.{ "main": "archiveType", "archiveType": ["postType"], "archivePostTypes": ["product"] }./product/ (or whatever the CPT's archive slug is) will now use this template.Trap: if the CPT has has_archive = false in its registration, there's no archive URL and the template has no context to render in. Fix the CPT registration or use a regular page + a Posts loop instead.
search: triggered by ?s=query or /?s=query. Use { "main": "search" } for search-results templates. Do not use { "main": "any" } unless you intentionally want a broad body-template fallback, because Bricks scores all body-type templates together.error: 404 template. Conditions typically { "main": "any" } too.If you don't create them, WP falls back to the default theme files (which Bricks sometimes renders minimally, sometimes not at all, depending on theme).
In the builder, the top-right has a Preview as dropdown. Use it to simulate different content types: Bricks evaluates conditions against the simulated context.
It does not simulate every frontend route, custom query, or plugin filter perfectly. For those, view the frontend.
| Hook | Purpose |
|---|---|
bricks/database/content_type | Override the WP context -> Bricks content_type mapping (includes/database.php:619) |
bricks/active_templates | Mutate the list of active templates after resolution (includes/database.php:707) |
bricks/get_templates | Filter the full template query result (includes/templates.php:1023) |
bricks/render_with_bricks | Whether Bricks renders at all for this request (includes/helpers.php:3159) |
See hooks-reference for the complete template hook list.
A template with no conditions does not match through screen_conditions() itself. find_template_id() adds narrow fallbacks for some template types: header/footer can score 0 when default templates are enabled, and a template whose type matches the current content type can score 1. Do not use empty conditions as a normal site-wide rule; use { "main": "any" } instead.
Template doesn't show where expected?
a. Open the builder -> the template -> Template settings -> Conditions. Does the current page match at all?
b. Another template of the same type has a higher score. Check WP Admin > Bricks > Templates: compare conditions across all templates of the same type.
c. Condition uses a CPT or taxonomy slug that changed. Slugs don't get live-migrated.
Template shows where not expected?
a. main: any on a template that should be specific. Replace with a more specific condition.
b. Condition list has an extra OR entry that's too broad.
Multiple templates "should" render, only one does?
a. Working as designed. Only one template per part wins. Use the Template element (inserts a section type) to compose.
Header is empty / page has no header?
a. No header template matches. Create one with { "main": "any" } as fallback.
b. Header template exists but its conditions do not match the current page.
Archive template not rendering on the CPT archive?
a. CPT has has_archive = false: no archive URL exists.
b. Check whether the intended scope is all archives, a post-type archive, or specific taxonomy terms; match the condition to that scope.
Content template wins but you wanted the "single" default?
a. A content template with score 2+ beats WP's default single. Remove the unwanted condition or delete the template.
main: any on a content template unless you really want it to cover every singular page.main: any with other conditions expecting AND semantics. Conditions are OR. If you need AND, author a single main: ids with the specific list.archive to content after it's been used: existing conditions assume the old type's rendering context.section templates don't self-render. They're building blocks for the Template element.entireWebsite or archiveTerm as main: those names exist nowhere in the schema and will be rejected.list-templates: enumerate all templates with type + conditions.get-template: full template content + settings.create-template, delete-template: template CRUD. Use set-template-settings and set-template-conditions for settings and condition changes.set-template-conditions: replace the templateConditions array (uses the canonical shape above).duplicate-post: copies a template including conditions and regenerates element ids.headers-footers: header/footer template rules + meta routing for element writes.popups: covers popup-type templates specifically.query-loops: covers archive/content template queries.components: for section-type templates and reusable content.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/bricks:bricks-templates-conditionsfrom bricks
npx claudepluginhub codeerhq/bricks-skills --plugin bricks46 skills in this plugin
/bricks-agent-repositoryHandle complex existing-site Bricks edits through advertised repository/workspace workflows when focused abilities cannot express the change./bricks-ai-tabDiagnose Bricks AI connection setup, ability toggles, dispatcher availability and disabled actions. Use for connection/availability problems./bricks-audit-design-systemAudit Bricks classes, variables, palettes and components, or carry out requested cleanup. Report-only audits do not authorize fixes./bricks-breakpointsRead or change Bricks responsive breakpoint definitions. Use for breakpoint configuration, not ordinary element styling at an existing breakpoint./bricks-browser-verifyInspect a Bricks page in a browser, compare it with a design or baseline, or verify a completed change. Inspection requests remain read-only./bricks-child-theme-patternsSet up or debug a Bricks child theme, including asset loading and extension registration. Use for theme-level PHP/files, not ordinary Builder edits.Other plugins' skills for the same job