PHP Themes Aren’t Dead
Ben Word on
Chris Coyier recently wrote on Noodling on WordPress in 2023:
What I always thought I wanted was to build themes with a modern component model. WordPress in the back, Astro on the front bb. But instead of that component model being a JavaScript framework, its Blocks, and PHP themes are dead. 🤷♀️
Modern has different meanings to different folks
The WordPress community started using the term “modern WordPress” over the last several years to describe workflows that involve using the block editor.
At Roots, we’re fans of the block editor and adopted it early on in our own workflows. Full Site Editing has finally started to mature over the last several years as well.
Chris is correct when it comes to missing out on modern WordPress momentum:
Certainly, you can just build a WordPress website the same way you could a decade ago … But is that prudent? Are you missing out on important and useful aspects of modern WordPress momentum? Probably!
Failing to adopt the block editor at this point isn’t a smart move. It’s very hard for anyone to argue that using the classic editor is a better experience for the folks that are using your WordPress sites.
Blocks should absolutely be adopted
If you’re still holding out on using the block editor… well, why are you still building WordPress sites?
Writing native blocks for the WordPress editor allows you to create high quality experiences for the users of your sites. While the documentation for Gutenberg is still lacking in areas, there’s at least wide community support for it by now.
Lots of developers use and love ACF, and ACF Blocks are certainly a way to quickly get running with the new WordPress editor. I’d argue that you should aim to replace any ACF Blocks that you implement as soon as possible with native blocks. While native blocks do take longer to develop, they will provide a better experience for your clients/users due to having more control over what’s possible to create with modern JavaScript and Gutenberg.
Modern WordPress without Block Themes
Is there still a place for PHP themes in the WordPress ecosystem? Absolutely! Block Themes are targeted towards the “no code” crowd. If you’re a modern PHP developer, you will have a worse experience developing FSE themes versus building a hybrid theme that uses both PHP along with the block editor.
FSE themes don’t use PHP, and instead use HTML comments to include both blocks and block template parts.
Block data is stored as HTML components, so dynamic data is still a problem that PHP addresses well. You could use an accompanying script to fetch the data to populate the block in the theme but that isn’t always desirable or appropriate. And, since PHP is always handling the initial request/response, doesn’t it make sense to do that data fetching there rather than a client-side REST call, when possible?
Server-side rendered blocks are called that because they are rendered on the server with PHP, and they fit the bill perfectly.
Sage, our WordPress starter theme, has been using the Laravel Blade templating engine since v9. With Blade comes the ability to utilize things like template inheritance along with Blade Components. You can even render your blocks with Blade templates.
Between Blade, Tailwind CSS, and Alpine.js, the WordPress sites I’ve been building these days feel more modern than ever.
Long live hybrid themes.