On this page
get_template_directory_uri(): string
Retrieves template directory URI for the active theme.
Return
string URI to active theme's template directory.
More Information
Notes
- Checks for SSL
- Does not return a trailing slash following the directory address
Source
File: wp-includes/theme.php. View all references
function get_template_directory_uri() {
$template = str_replace( '%2F', '/', rawurlencode( get_template() ) );
$theme_root_uri = get_theme_root_uri( $template );
$template_dir_uri = "$theme_root_uri/$template";
/**
* Filters the active theme directory URI.
*
* @since 1.5.0
*
* @param string $template_dir_uri The URI of the active theme directory.
* @param string $template Directory name of the active theme.
* @param string $theme_root_uri The themes root URI.
*/
return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
}
Hooks
- apply_filters( 'template_directory_uri',
string $template_dir_uri ,string $template ,string $theme_root_uri ) -
Filters the active theme directory URI.
Related
Uses
| Uses | Description |
|---|---|
| get_theme_root_uri() wp-includes/theme.php | Retrieves URI for themes directory. |
| get_template() wp-includes/theme.php | Retrieves name of the active theme. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| get_parent_theme_file_uri() wp-includes/link-template.php | Retrieves the URL of a file in the parent theme. |
| get_theme_file_uri() wp-includes/link-template.php | Retrieves the URL of a file in the theme. |
| get_editor_stylesheets() wp-includes/theme.php | Retrieves any registered editor stylesheet URLs. |
| Custom_Image_Header::get_default_header_images() wp-admin/includes/class-custom-image-header.php | Gets the details of default header images if defined. |
| Custom_Image_Header::step_1() wp-admin/includes/class-custom-image-header.php | Display first step of custom header image page. |
| Custom_Image_Header::reset_header_image() wp-admin/includes/class-custom-image-header.php | Reset a header image to the default image for the theme. |
| Custom_Image_Header::process_default_headers() wp-admin/includes/class-custom-image-header.php | Process the default headers |
| WP_Customize_Manager::register_controls() wp-includes/class-wp-customize-manager.php | Registers some default controls. |
| _get_random_header_data() wp-includes/theme.php | Gets random header image data from registered images in theme. |
| get_custom_header() wp-includes/theme.php | Gets the header image data. |
| get_theme_mod() wp-includes/theme.php | Retrieves theme modification value for the active theme. |
| get_bloginfo() wp-includes/general-template.php | Retrieves information about the current site. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_template_directory_uri