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 path to the theme's directory
- 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
- The folder name of the current 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->Name . " is version " . $my_theme->Version;
?>
Display the Current Theme Author URI
<?php
$my_theme = wp_get_theme();
echo $my_theme->{'Author URI'};
?>
Or,
<?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.