Since talking about WordPress templating, I’ve covered some different engines that are available:
If you’re looking at Mustache, then you may be interested in Handlebars, and if you’re looking at Blade, then I highly recommend checking out Sage from the Roots team.
But for this final post, I’m going to continue with Timber which is what I introduced yesterday. I’m not so much about which is being used (as they all have their tradeoffs) as long as it’s consistent.
If you’ve not been following along with this series and you’re just getting started with templating, I recommend reading the first two parts of the series:
- How It Is
- HTML Calling PHP
From there, we’re going to break down the concept into two parts:
- understanding what templating is,
- how templating can work within WordPress.
The challenge, of course, comes in that we have “WordPress templates” and then we’re talking about using a templating engine to change up WordPress templates, how they work, how data is injected into them, and so on.
But I’ll do my best to try to clarify each part.
Yesterday, I sketched out how to conceptualize how many of us are likely used to working with WordPress templates.
To be clear, we can’t help but include template tags because that’s the nature of how WordPress and general PHP-based content management systems work.
The problem comes whenever we’re working with templates that contain code making more complex calls to various APIs. Though I demonstrated this using WP_Query (and will continue to do so), it’s not just that query.
Anyway, though, what are we supposed to do with this?
When I first started thinking about templating in WordPress, I thought about regarding two aspects:
- content specifically for members,
- content that could break down into a single post.
But the more I thought about it, the more I realized that it could (and arguably should) be explained over the course of a few posts.
So I’m going be breaking down the current state of WordPress templating and then practical ways we can take organize, say, our plugins so that we’re using standard PHP.
For starts, though, I want to take a look how we often see templates written within the context of both WordPress themes and plugins.