Template files are usually used in themes and child themes, but you can also load template files from a plugin.

It’s not to difficult to create your own template loader, but you can also find the Gamajo_Template_Loader on GitHub by Gary Jones.

To use this class:

1. Create a file in your plugin and copy the Gamajo_Template_Loader class into it.
2. Create a new class that extends the Gamajo_Template_Loader. Find an example here
3. Override the class properties for your plugin, these are:
$filter_prefix, $theme_template_directory, $plugin_directory.

You can also find a full plugin example by Pippin Williamson from pippinsplugins.com using the Gamajo_Template_Loader

How to load template files in a plugin
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *