The display_theme() WordPress PHP function prints a theme on the Install Themes pages.
Usage
To use the display_theme() function, pass it a $theme
object as an argument.
$theme = wp_get_theme(); display_theme($theme);
Parameters
$theme
(WP_Theme object – Required): The theme object that you want to display on the Install Themes pages.
More Information
See WordPress Developer Resources: display_theme()
Examples
Display Active Theme
This example displays the active theme on the Install Themes pages.
$active_theme = wp_get_theme(); // Get active theme display_theme($active_theme); // Display the active theme
Display Parent Theme
If your active theme is a child theme, this code will display its parent theme.
$child_theme = wp_get_theme(); // Get active theme if ($child_theme->parent()) { // Check if it is a child theme $parent_theme = $child_theme->parent(); // Get the parent theme display_theme($parent_theme); // Display the parent theme }
Display All Installed Themes
This code lists all installed themes on your WordPress site.
$all_themes = wp_get_themes(); // Get all themes foreach ($all_themes as $theme) { // Loop through each theme display_theme($theme); // Display the theme }
Display Theme by Text Domain
Displays a theme using its text domain.
$theme = wp_get_theme('twentytwenty'); // Get theme by text domain display_theme($theme); // Display the theme
Display Theme by Path
This code displays a theme using its path.
$theme = wp_get_theme('/path/to/theme'); // Get theme by its path display_theme($theme); // Display the theme