wp_get_theme

Home » Functions » wp_get_theme

Function Name: wp_get_theme

If you are developing a WordPress theme or plugin, you may need to retrieve information about the active theme, such as its name, version, author, and description. This is where the wp_get_theme() function comes in handy. The wp_get_theme() function is used to get the details of the currently active theme. It returns an instance of the WP_Theme class, which contains all the information about the theme.

The information returned by wp_get_theme() includes the following:

  • Theme Name
  • Theme URI
  • Author
  • Author URI
  • Description
  • Version
  • Template
  • Status
  • Tags
  • Text Domain

Here’s an example usage code:

$theme = wp_get_theme();
echo 'Theme Name: ' . $theme->get( 'Name' ) . '<br>';
echo 'Theme Version: ' . $theme->get( 'Version' ) . '<br>';
echo 'Theme Author: ' . $theme->get( 'Author' ) . '<br>';
echo 'Theme Description: ' . $theme->get( 'Description' ) . '<br>';

This code will get the details of the active theme and display the name, version, author, and description on the screen. You can use this information to create dynamic templates, customize the appearance of your theme, or add theme-specific functionality to your plugin.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.