Load custom template with template_include / locate_template
-
Hi,
I want to load a custom template and found this example in codex:
http://codex.wordpress.org/Plugin_API/Filter_Reference/template_includeThis example includes a new template on a page called ‘portfolio’ if the new template file was found.
add_filter( 'template_include', 'portfolio_page_template', 99 ); function portfolio_page_template( $template ) { if ( is_page( 'portfolio' ) ) { $new_template = locate_template( array( 'portfolio-page-template.php' ) ); if ( '' != $new_template ) { return $new_template ; } } return $template; }I want to load a custom template from a plugin (so not from theme), so I should adjust this part I guess:
$new_template = locate_template( array( 'portfolio-page-template.php' ) );Who can tell me how to load a custom template from the plugin directory?
Guido
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Load custom template with template_include / locate_template’ is closed to new replies.