On this page
WP_Theme::get_template_directory(): string
Returns the absolute path to the directory of a theme’s “template” files.
Description
In the case of a child theme, this is the absolute path to the directory of the parent theme’s files.
Return
string Absolute path of the template directory.
Source
File: wp-includes/class-wp-theme.php. View all references
public function get_template_directory() {
if ( $this->parent() ) {
$theme_root = $this->parent()->theme_root;
} else {
$theme_root = $this->theme_root;
}
return $theme_root . '/' . $this->template;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Theme::parent() wp-includes/class-wp-theme.php | Returns reference to the parent theme. |
Used By
| Used By | Description |
|---|---|
| WP_Theme::get_file_path() wp-includes/class-wp-theme.php | Retrieves the path of a file in the theme. |
| WP_Theme::get_files() wp-includes/class-wp-theme.php | Returns files in the theme’s directory. |
| WP_Theme::__get() wp-includes/class-wp-theme.php | __get() magic method for properties formerly returned by current_theme_info() |
| WP_Theme::offsetGet() wp-includes/class-wp-theme.php |
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory