Software Engineering in WordPress, PHP, and Backend Development

Tag: Page Template Example

How To Include a Page Template in a WordPress Plugin

Last March, I wrote a post on How To Include a Page Template in a WordPress Plugin. The post and the associated code was a proof-of-concept that was never intended to be used in production environments.

But since then, I’ve received a few pull requests and have implemented some additional changes that have brought this plugin up to a stable `1.0.0` that I believe is capable of being used in a more stable setting.

Continue reading

Including a WordPress Page Template in a Plugin

Note that this plugin is just a working proof-of-concept. Do not use this in a production environment.

One of the challenges of working with templates within the context of WordPress plugin development is that there’s no easy way to bundle templates with your plugin and register them with WordPress.

Template are usually relegated to theme development. And rightly so, correct?

After all, page templates are used to provide layout and presentation which is precisely what themes are meant to provide.

But if you’re working on a larger, more complex plugin that introduces custom post types, page templates, and other advanced functionality then there may be a use case in which bundling templates with your plugin is necessary.

I’ve hit up against this exact issue in a recent project, so I thought I’d share the basics of how I solved the problem, and then provide an example plugin to make the process of registering page templates with WordPress themes a bit easier.

Continue reading

© 2024 Tom McFarlin

Theme by Anders NorenUp ↑