WordPress.org

Codex

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

Example Output

var_dump(wp_get_theme()); results :

object(WP_Theme)[916]
  public 'update' => boolean false
  private 'theme_root' => string 'home/path/wp-content/themes' (length=77)
  private 'headers' => 
    array (size=11)
      'Name' => string 'mytheme' (length=7)
      'ThemeURI' => string 'http://example.com/' (length=22)
      'Description' => string 'Description' (length=11)
      'Author' => string 'Something Here' (length=14)
      'AuthorURI' => string 'http://example.com/' (length=22)
      'Version' => string '1.0.0' (length=5)
      'Template' => string '' (length=0)
      'Status' => string '' (length=0)
      'Tags' => string 'custom-background, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready' (length=98)
      'TextDomain' => string 'mytheme' (length=7)
      'DomainPath' => string '' (length=0)
  private 'headers_sanitized' => null
  private 'name_translated' => null
  private 'errors' => null
  private 'stylesheet' => string 'mytheme' (length=7)
  private 'template' => string 'mytheme' (length=7)
  private 'parent' => null
  private 'theme_root_uri' => null
  private 'textdomain_loaded' => null
  private 'cache_hash' => string 'ca9dd01f01f2a5cb4616a776eff52690' (length=32)

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.