The majority of the work that I do right now focuses on custom plugins or utilities that work on top of WordPress.
If you were to conceptualize how many of the projects that I build are put together, you’d review WordPress (and all that it entails) as the foundation, and then the code has having a layer that communicates with WordPress, and that may communicate with third-party APIs.
When doing this, though, there’s often a front-end component that requires I render information into templates. Though building templates for WordPress aren’t inherently difficult (though I do wish we had a bit more than template tags – such as a templating engine, that’s another post), I think it’s worth looking at a couple of ways that we can handle custom templates that we bundled with plugins.
One of the first questions that’s often raised with this statement, though, is
Why would you include custom templates in a plugin?
And I get it on some levels.
- Keeping templates in a plugin blurs the lines a bit between themes and plugins especially when you leave themes for presentation and plugins for business logic,
- Asking users to copy theme files on from one location to another is bad user experience.
But there are a few rebuttles or perhaps outright exceptions to the above cases.