WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp get theme

Description

Gets a WP_Theme object for a theme.

Usage

<?php $theme wp_get_theme$stylesheet$theme_root ); ?>

Parameters

$stylesheet
(string) (Optional) Directory name for the theme. Defaults to current theme.
Default: Null
$theme_root
(string) (Optional) Absolute path of the theme root to look in. If not specified, the value returned by get_raw_theme_root() will be used.
Default: Null

Return Values

This function returns an instance of the WP_Theme object, which includes the following properties:

Name 
Theme name as given in theme's style.css
ThemeURI 
The URI of the theme's webpage
Description 
The description of the theme
Author 
The theme's author
AuthorURI 
The website of the theme author
Version 
The version of the theme
Template 
(Optional — used in a child theme) The folder name of the parent theme
Status 
If the theme is published
Tags 
Tags used to describe the theme
TextDomain 
The text domain used in the theme for translation purposes
DomainPath 
Path to the theme translation files

Examples

Echo the name of the current active theme.

<?php
echo wp_get_theme();
?>

Echo the name of an installed theme.

<?php
$my_theme = wp_get_theme( 'twentyten' );
if ( $my_theme->exists() )
	echo $my_theme;
?>

Display the Current Theme's Version

<?php
$my_theme = wp_get_theme();
echo $my_theme->get( 'Name' ) . " is version " . $my_theme->get( 'Version' );
?>

Display the Current Theme Author URI

<?php
$my_theme = wp_get_theme();
echo $my_theme->get( 'AuthorURI' );
?>

Get Other Data: Text Domain & Theme URI

<?php
$my_theme = wp_get_theme();
echo $my_theme->get( 'TextDomain' );
echo $my_theme->get( 'ThemeURI' );
?>

Change Log

Since: 3.4.0

Source File

wp_get_theme() is located in wp-includes/theme.php.

See also index of Function Reference and index of Template Tags.