apply_filters( 'template_include', string $template )
Filters the path of the current template before including it.
Description Description
Parameters Parameters
- $template
-
(string) The path of the template to include.
Source Source
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
This 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; }Expand full source codeCollapse full source code