From e52a1de268d409918613b96f4b01fd8119c0c915 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Fri, 15 May 2026 07:35:12 +0200 Subject: [PATCH] fix(bricks): correct Single Post template conditions format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bricks's templateConditions for single posts expects: main: 'postType', postType: ['post'] (array of post types) NOT the singular/object variant I'd used: main: 'singular', object: 'post' The wrong format triggered "Invalid post type" when opening the template in the Bricks builder editor — Bricks's editor couldn't parse the condition and refused to load the template. Source : wp-content/themes/bricks/includes/admin.php line 1101 — the switch case for 'postType' confirms the expected shape. For 'any' (entire website, used by Header/Footer templates), no extra keys are needed beyond main='any'. Section/single templates need this postType array form. Co-Authored-By: Claude Opus 4.7 (1M context) --- tools/av-generate-insights.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/av-generate-insights.php b/tools/av-generate-insights.php index 555d696..1af97ee 100644 --- a/tools/av-generate-insights.php +++ b/tools/av-generate-insights.php @@ -254,11 +254,18 @@ function av_ensure_insight_single_template() { ]); } - // Mark as type=single + apply to all single posts + // Mark as type=single + apply to all single posts. + // Bricks expects main='postType' + postType=['post'] (array) — not the + // 'singular' + 'object' variant. Using the wrong format triggers + // 'Invalid post type' when opening the template in the builder. update_post_meta($tpl_id, '_bricks_template_type', 'single'); $settings = get_post_meta($tpl_id, '_bricks_template_settings', true) ?: []; $settings['templateConditions'] = [ - ['id' => substr(md5('postSingle'), 0, 6), 'main' => 'singular', 'object' => 'post'], + [ + 'id' => substr(md5('postSingle'), 0, 6), + 'main' => 'postType', + 'postType' => ['post'], + ], ]; update_post_meta($tpl_id, '_bricks_template_settings', $settings);