We run around 30 WordPress sites manly which we have acquisition and a few which we have built from the ground up using Sage. Therefore, we have two mediums, one using blade and one using standard php for templates.
We’re developing a plugin which will need to include template files. The idea of the plugin is that it will be plug and play, there should be no editing or copying plugin template file to the theme etc, the plugin should hook into the filter template_include
and load the template for the given page from the plugin.
Example
add_filter('template_include', [$this, 'setTemplate']);
public function setTemplate($template)
{
if (is_singular('reviews')) {
$template = WP_PLUGIN_DIR .'/'. plugin_basename(dirname(__FILE__)) . '/Reviews/single-reviews.php';
}
return $template;
}
Which works perfectly. There is just one major issue, we’re missing the header and footer, and returned the warning. Which I understand as it’s looking now for a header.php within /views.
Has anyone been any to solve this issue? Is there a solution.