WordPress at a glance

get_stylesheet_uri() WP 1.5.0

Retrieves the URI of the current theme stylesheet file (style.css).

The stylesheet file name is always style.css, that's why this function use get_stylesheet_directory_uri() and append the name to the end: http://domain/path/style.css.

If a child theme is used, this function returns the URL to the child theme, not to a parent one.

✈ 1 time = 0.000039s = very fast | 50000 times = 0.78s = very fast | PHP 7.0.2, WP 4.4.2
Hooks from the function
Return

String. URL of the stylesheet file style.css of the current theme.

Usage

get_stylesheet_uri();

Examples

#1 Retrieves the URI of current theme stylesheet

echo get_stylesheet_uri();
// output: http://example.com/wp-content/themes/wp-kama/style.css

#2 Load the current theme stylesheet

If you want to load a stylesheet (CSS) file, you should use wp_enqueue_style() function:

add_action( 'wp_enqueue_scripts', 'enqueue_mytheme_style' );
function enqueue_mytheme_style() {
	wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
}

Reed more: Better way to include child theme styles (along with parent theme styles).

Changelog

Since 1.5.0 Introduced.

Code of get stylesheet uri: wp-includes/theme.php WP 5.2.2

<?php
function get_stylesheet_uri() {
	$stylesheet_dir_uri = get_stylesheet_directory_uri();
	$stylesheet_uri     = $stylesheet_dir_uri . '/style.css';
	/**
	 * Filters the URI of the current theme stylesheet.
	 *
	 * @since 1.5.0
	 *
	 * @param string $stylesheet_uri     Stylesheet URI for the current theme/child theme.
	 * @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme.
	 */
	return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
}

Related Functions

From tag: Link (URL)

More from category: Theme files connection

No comments
    Hello, !     Log In . Register