WP_Theme::get_template() WordPress Method
The WP_Theme::get_template() method is used to retrieve the path of a template file within a theme. This method is useful for retrieving the path of a template file so that it can be included within another template file. For example, if you wanted to include the contents of a sidebar template file within a page template file, you would use the WP_Theme::get_template() method to retrieve the path of the sidebar template file.
WP_Theme::get_template() #
Returns the directory name of the theme’s “template” files, inside the theme root.
Description
In the case of a child theme, this is the directory name of the parent theme. Otherwise, the get_template() is the same as get_stylesheet().
Return
(string) Template
Source
File: wp-includes/class-wp-theme.php
public function get_template() { return $this->template; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |