I have recently been altering some features in Woocommerce Subscriptions that required diving into some “templates” that controlled the layout and functionality of grouped products. What a mess.
Perhaps I was expecting too much and had hoped to see some clean HTML with placeholders for data coming from the code. But the specific template in this example was filled with dense code structures interwoven with HTML which made it hard to understand and difficult to re-model.
If you’ve spent any significant time in the Drupal ecosystem or working with modern PHP frameworks like Symfony, stepping back into a “traditional” WordPress theme can feel like a sudden architectural regression. As developers, we’ve fought hard for the separation of concerns. We know that the logic of how data is fetched should never live in the same file as the markup that defines how it looks.
Yet, open almost any popular WordPress template and you’ll find the “Spaghetti Monster” alive and well.
The Problem with “PHP-First” Theming
In a standard WordPress .php template, the HTML is often strangled by impenetrable blocks of logic. You’ll see complex nested if statements, global variable declarations, and the ubiquitous “Loop” all competing for space with your <div> tags.
For a developer with a background in Twig (the standard in Drupal 8+), this is more than just an eyesore—it’s a maintenance liability. When business logic and presentation are tightly coupled:
- Readability plummets: Finding where a class starts and ends involves squinting through dozens of lines of
<?php ?>tags. - Security risks increase: Without an auto-escaping engine, it’s all too easy to forget an
esc_html()oresc_attr(), leaving the site vulnerable. - Collaboration breaks: Front-end designers who are masters of CSS shouldn’t have to parse complex PHP logic just to move a sidebar.
The Twig Ideal: Clean HTML with Placeholders
Coming from Drupal, we know there is a better way. Imagine a world where your template looks like actual HTML. Instead of a mess of PHP tags, you have clean, semantic markup with intuitive placeholders:
Twig
<article class="post">
<h2>{{ post.title }}</h2>
<div class="content">
{{ post.content }}
</div>
</article>
This is the beauty of a templating engine. It treats the template as a View, not a playground for database queries. The PHP handles the heavy lifting—the “Controller” logic—and passes a clean data object to a .twig file. The result is a codebase that is easier to debug, faster to theme, and significantly more professional.
Moving Forward
While WordPress core remains rooted in its legacy ways, tools like Timber have proven that we can bring the sanity of Twig to the WordPress world. It allows us to write themes that look like they belong in 2026, not 2006.
If we want to build a more robust, maintainable web, it’s time to stop writing “code” in our templates and start writing templates again.
How to Use Timber and Twig for Modern WordPress Development
This video provides a practical walkthrough of how to integrate Twig into WordPress to achieve the clean separation of concerns discussed in the post.

