Using WordPress ‘get_theme_data()’ PHP function

The get_theme_data() WordPress PHP function retrieves theme data from a parsed theme file.

Usage

get_theme_data( $theme_file )

Custom Example:

$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
echo 'Theme Name: ' . $theme_data['Name'];

Parameters

  • $theme_file (string) – The theme file path. Required.

More information

See WordPress Developer Resources: get_theme_data()

Examples

Get Theme Name

Get the theme name from the current theme’s style.css file.

$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
echo 'Theme Name: ' . $theme_data['Name'];

Get Theme Author

Get the theme author from the current theme’s style.css file.

$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
echo 'Theme Author: ' . $theme_data['Author'];

Get Theme Version

Get the theme version from the current theme’s style.css file.

$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
echo 'Theme Version: ' . $theme_data['Version'];

Get Theme URI

Get the theme URI from the current theme’s style.css file.

$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
echo 'Theme URI: ' . $theme_data['ThemeURI'];

Get Theme Description

Get the theme description from the current theme’s style.css file.

$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
echo 'Theme Description: ' . $theme_data['Description'];