On this page
get_stylesheet_directory_uri(): string
Retrieves stylesheet directory URI for the active theme.
Return
string URI to active theme's stylesheet directory.
More Information
- The returned URI does not contain a trailing slash.
- This function returns a properly-formed URI; in other words, it will be a web-address (starting with http:// or https:// for SSL). As such, it is most appropriately used for links, referencing additional stylesheets, or probably most commonly, images.
- In the event a child theme is being used, this function will return the child’s theme directory URI. Use get_template_directory_uri() to avoid being overridden by a child theme.
- If you want to include a local file in PHP, use get_stylesheet_directory() instead.
Source
File: wp-includes/theme.php. View all references
function get_stylesheet_directory_uri() {
$stylesheet = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
$theme_root_uri = get_theme_root_uri( $stylesheet );
$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
/**
* Filters the stylesheet directory URI.
*
* @since 1.5.0
*
* @param string $stylesheet_dir_uri Stylesheet directory URI.
* @param string $stylesheet Name of the activated theme's directory.
* @param string $theme_root_uri Themes root URI.
*/
return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
}
Hooks
- apply_filters( 'stylesheet_directory_uri',
string $stylesheet_dir_uri ,string $stylesheet ,string $theme_root_uri ) -
Filters the stylesheet directory URI.
Related
Uses
| Uses | Description |
|---|---|
| get_theme_root_uri() wp-includes/theme.php | Retrieves URI for themes directory. |
| get_stylesheet() wp-includes/theme.php | Retrieves name of the current stylesheet. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| 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_stylesheet_uri() wp-includes/theme.php | Retrieves stylesheet URI for the active theme. |
| get_locale_stylesheet_uri() wp-includes/theme.php | Retrieves the localized stylesheet URI. |
| 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_stylesheet_directory_uri