Dec 11, 2015
Load Template From WordPress Plugin
You can load a template file from your plugin using the template_include
filter, with code similar to this:
function km_include_gym_dashboard_page_template( $template ) {
if ( is_page( 'gym-dashboard' ) ) {
return plugin_dir_path( __FILE__ ) . 'templates/content-gym-dashboard.php';
}
return $template;
}
add_filter( 'template_include', 'km_include_gym_dashboard_page_template', 99 );
If youβre looking for something more robust that checks the child and parent themes before falling back to the plugin template, check out Gamajo Template Loader.