get_stylesheet_directory_uri

Home » Functions » get_stylesheet_directory_uri

The get_stylesheet_directory_uri() function is a WordPress function that retrieves the URI (Uniform Resource Identifier) of the current active theme’s stylesheet directory. It can be used to get the URL of the current theme’s directory, which is useful for loading any additional stylesheets or scripts that the theme may require.

This function returns the URL of the current active theme’s stylesheet directory, which can be used for various purposes such as loading additional stylesheets or scripts. By default, this function will retrieve the URI for the current active theme’s stylesheet directory. However, it also accepts a parameter that allows you to specify the directory for a different theme.

For example, if you want to load a stylesheet located in your theme’s directory, you can use the get_stylesheet_directory_uri() function to retrieve the URL of the current theme’s directory. Here’s an example usage code:

<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" type="text/css" media="all" />

In this code, the get_stylesheet_directory_uri() function is used to retrieve the URL of the current active theme’s stylesheet directory, which is then concatenated with the path to the style.css file to create the URL for the stylesheet. This code can be added to your theme’s header.php file to load the stylesheet on all pages.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.