get_stylesheet

Home » Functions » get_stylesheet

The get_stylesheet function in WordPress is used to retrieve the URL of the stylesheet currently being used by the active theme. This function can be useful for developers who want to enqueue additional stylesheets or modify the active stylesheet using hooks and filters.

When the function is called, it first checks if a child theme is being used. If a child theme is active, it will return the URL of the child theme’s stylesheet. If a child theme is not active, it will return the URL of the parent theme’s stylesheet.

Here’s an example usage code:

$stylesheet_url = get_stylesheet();
echo $stylesheet_url; // Outputs the URL of the active stylesheet

In the above example, the URL of the active stylesheet is retrieved using get_stylesheet and stored in the $stylesheet_url variable. The URL is then echoed to the page using echo.

Overall, the get_stylesheet function can be a useful tool for developers who need to access the active stylesheet in their WordPress projects.

Learn More on WordPress.org

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