The title of this post is somewhat misleading as I’m not actually sharing how to programmatically populate a WordPress template – instead, I’m walking through the process of populating a page that also has a page template applied to it.
Anyway, creating WordPress templates is easy business:
- Create the template file in the theme directory
- Give the template file the proper header comments
- Fill out the template with the proper markup
Back in March, I shared a proof-of-concept plugin for including a template file in a plugin. If you browse through the comments, note that there’s a lot of discussion on how to do it, why one way is better than the others, and so on.
But as I’ve continued to work on a project in which I include templates in plugins, I’ve also been working on populating template-based pages with content from HTML files.
Here’s how I’ve been working to programmatically populate a WordPress template.