From e3e9b9f2be4218ee45632b7eb9049b24e962ef8f Mon Sep 17 00:00:00 2001 From: magdev Date: Wed, 11 Feb 2026 09:54:16 +0100 Subject: [PATCH] fix: make page title

conditional to prevent double headings (v1.0.3) When plugins inject content via TwigService with empty post.title, the theme's

is now skipped. Prevents duplicate headings on plugin-rendered pages that provide their own titles. Co-Authored-By: Claude --- CLAUDE.md | 15 +++++++++++++++ style.css | 2 +- views/pages/page.html.twig | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 085bb08..e64355a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -193,6 +193,21 @@ Build steps (in order): ## Session History +### Session 11 — v1.0.3 Conditional Page Title (2026-02-11) + +**Completed:** Made `

` on page template conditional to prevent double headings when plugins provide their own titles. + +**What was fixed:** + +- `views/pages/page.html.twig` now wraps `

{{ post.title }}

` in `{% if post.title is not empty %}` guard +- When a plugin passes empty `post.title` via `render_via_theme_twig()`, the theme's `

` is skipped +- Prevents duplicate headings on pages where plugin templates render their own `

` with richer context (icons, badges, meta) + +**Key learnings:** + +- Plugins that delegate rendering to the parent theme via `TwigService` should be able to opt out of the theme's `

` by passing empty `post.title` +- The `is not empty` Twig test correctly handles both `null` and empty string `''` + ### Session 10 — v1.0.2 Title Tag Fix (2026-02-10) **Completed:** Fixed missing HTML `` tag on all pages rendered by the theme's Twig pipeline. diff --git a/style.css b/style.css index ea3de58..b760105 100644 --- a/style.css +++ b/style.css @@ -7,7 +7,7 @@ Description: A modern WordPress Block Theme built from scratch with Bootstrap 5. Requires at least: 6.7 Tested up to: 6.7 Requires PHP: 8.3 -Version: 1.0.2 +Version: 1.0.3 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: wp-bootstrap diff --git a/views/pages/page.html.twig b/views/pages/page.html.twig index 329d016..3403b78 100644 --- a/views/pages/page.html.twig +++ b/views/pages/page.html.twig @@ -10,7 +10,9 @@ </figure> {% endif %} - <h1>{{ post.title }}</h1> + {% if post.title is not empty %} + <h1>{{ post.title }}</h1> + {% endif %} <div class="post-content"> {{ post.content|raw }}