The current_theme_info() WordPress PHP function retrieves information about the currently active theme in a WordPress installation.
Usage
Here’s a simple way to use the function:
$theme_info = current_theme_info(); echo 'The current theme is: ' . $theme_info->name;
In this example, the function returns an object containing details about the currently active theme. We then echo the name of the current theme.
Parameters
- This function does not accept any parameters.
More information
See WordPress Developer Resources: current_theme_info()
This function was deprecated in WordPress version 3.4.0. It’s recommended to use wp_get_theme()
instead.
Examples
Getting Theme Name
Get the name of the current theme.
$theme_info = current_theme_info(); echo 'The current theme name is: ' . $theme_info->name;
Getting Theme Title
Get the title of the current theme.
$theme_info = current_theme_info(); echo 'The current theme title is: ' . $theme_info->title;
Getting Theme Version
Get the version of the current theme.
$theme_info = current_theme_info(); echo 'The current theme version is: ' . $theme_info->version;
Getting Theme’s Template Directory URI
Get the URI of the current theme’s template directory.
$theme_info = current_theme_info(); echo 'The current theme\'s template directory URI is: ' . $theme_info->template_dir;
Getting Theme’s Screenshot
Get the URL of the screenshot for the current theme.
$theme_info = current_theme_info(); echo 'The current theme\'s screenshot URL is: ' . $theme_info->screenshot;
In all these examples, current_theme_info() is used to fetch different details about the currently active theme in a WordPress site.