get_stylesheet_directory()WP 1.5.0

Retrieve stylesheet directory path for current theme.

1 time — 0.000027 sec (very fast) | 50000 times — 0.28 sec (very fast) | PHP 7.0.2, WP 4.4.1
Hooks from the function

Return

String. Path to active theme's stylesheet directory.

Usage

get_stylesheet_directory();

Examples

0

#1 Demo

echo get_stylesheet_directory();
// return: /home/k/kama/example.com/public_html/wp-content/themes/themename
0

#2 Connect the myfile.php file for current theme:

The example shows how to use the function. Use this code in the parent theme to support the child theme:

require_once get_stylesheet_directory(). '/includes/myfile.php';

Changelog

Since 1.5.0 Introduced.
Since 6.4.0 Memoizes filter execution so that it only runs once for the current theme.
Since 6.4.2 Memoization removed.

get_stylesheet_directory() code WP 6.6.2

function get_stylesheet_directory() {
	$stylesheet     = get_stylesheet();
	$theme_root     = get_theme_root( $stylesheet );
	$stylesheet_dir = "$theme_root/$stylesheet";

	/**
	 * Filters the stylesheet directory path for the active theme.
	 *
	 * @since 1.5.0
	 *
	 * @param string $stylesheet_dir Absolute path to the active theme.
	 * @param string $stylesheet     Directory name of the active theme.
	 * @param string $theme_root     Absolute path to themes directory.
	 */
	return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
}