I am creating a plugin which requires use of custom templates so using the following code to use the templates:
add_filter('template_include', 'hhavideo_set_template');
function hhavideo_set_template( $template ){
if(is_archive('hhavideo') && 'archive-hhavideo.php' != $template ){
$template = include( plugin_dir_path( __FILE__ ) . 'templates/archive-hhavideo.php');
}
if(is_singular('hhavideo') && 'single-hhavideo.php' != $template ){
$template = include( plugin_dir_path( __FILE__ ) . 'templates/single-hhavideo.php');
}
return $template;
}
When that code is used, both templates crash my browser (Firefox), I sometimes get the error message that I have used the maximum execution time of 60 seconds.
The templates only have get_header and get_footer in them, the site runs perfectly fine on other pages.
What am I doing wrong, is there a better way to call the template files from the plugin?
Edit: Error I am now getting:
Warning: include(1) [function.include]: failed to open stream: No such file or directory in /wp-includes/template-loader.php on line 74
is_archive()
does not accept any parameters