WordPress at a glance

get_stylesheet() WP 1.5.0

Retrieve the name of the current theme directory.

This function retrieves the data with get_option('stylesheet').

The advantage of this function is that it passes the data through the stylesheet filter that plugins can use.

Works based on: get_option()
✈ 1 time = 0.003651s = very slow | 50000 times = 1.97s = fast | PHP 7.1.5, WP 4.8.2
Hooks in function
Return

String. Stylesheet name.

Usage

get_stylesheet();

Examples

#1 Output the name (folder name) of the current theme

Suppose we are using "twentytwelve" theme, let's output it's folder name:

echo get_stylesheet(); 

// output: twentytwelve

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

<?php
function get_stylesheet() {
	/**
	 * Filters the name of current stylesheet.
	 *
	 * @since 1.5.0
	 *
	 * @param string $stylesheet Name of the current stylesheet.
	 */
	return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );
}

Related Functions

From category: Other Theme Functions

No comments
    Hello, !     Log In . Register