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.