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 directory
$theme_directory = get_stylesheet_directory();
echo "Theme directory: " . $theme_directory;
// Example 2: Include a file from the theme's directory
$file_path = get_stylesheet_directory() . '/includes/custom-functions.php';
if (file_exists($file_path)) {
include $file_path;
} else {
echo "File not found.";
}
// Example 3: Enqueue a stylesheet from the theme's directory
function enqueue_custom_styles() {
wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/css/custom-style.css' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_custom_styles' );