Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

get_stylesheet_directory

Function Description:

Retrieves stylesheet directory path for the active theme.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Get the path to the current theme's stylesheet directory
$stylesheet_directory = get_stylesheet_directory();
echo "The path to the current theme's stylesheet directory is: " . $stylesheet_directory;
// Example 2: Include a file from the current theme's stylesheet directory
$stylesheet_directory = get_stylesheet_directory();
include $stylesheet_directory . '/custom-file.php';
// Example 3: Check if a specific file exists in the current theme's stylesheet directory
$stylesheet_directory = get_stylesheet_directory();
if ( file_exists( $stylesheet_directory . '/custom-file.php' ) ) {
    echo 'The file custom-file.php exists in the current theme\'s stylesheet directory.';
} else {
    echo 'The file custom-file.php does not exist in the current theme\'s stylesheet directory.';
}