get_template()WP 1.5.0

Retrieve name of the current theme.

1 time — 0.0022421 sec (very slow) | 50000 times — 2.09 sec (fast) | PHP 7.3.20, WP 5.6
Hooks from the function

Return

String. Template name.

Usage

get_template();

Examples

0

#1 Get the name of the current Theme

For example, if your current active theme is named wp-kama, then:

$template = get_template();

echo esc_html( $template ); // output: wp-kama

Note that the function will return the name of the parent theme, not the child theme, even if the child theme is activated.

Use get_stylesheet() to get the current theme, regardless of whether it is a child or parent theme.

Changelog

Since 1.5.0 Introduced.

get_template() code WP 6.4.3

function get_template() {
	/**
	 * Filters the name of the active theme.
	 *
	 * @since 1.5.0
	 *
	 * @param string $template active theme's directory name.
	 */
	return apply_filters( 'template', get_option( 'template' ) );
}