Need to include and redirect template from plugin

Your portfolio_newpage_template function does not result in a 404 when I try it, but it is not going to work either. locate_template will always load from theme directories, so it will never find your plugin file. You can see that in the source. __FILE__ is going to refer to the file with the function in it, which you say is a plugin, so what you have done will not work.

Just include your file and die.

add_filter( 'template_include', 'portfolio_newpage_template', 99 );
function portfolio_newpage_template( $template ) {  
  get_header();
  include('/some/file/path/file.php');
  get_footer();
  die;
}

Leave a Comment