wp_get_theme( string $stylesheet = '', string $theme_root = '' ): WP_Theme
- Since
- 3.4.0
- Source
wp-includes/theme.php:117
Gets a WP_Theme object for a theme.
Parameters
$stylesheetstringoptional- Directory name for the theme. Defaults to active theme.Default:
'' $theme_rootstringoptional- Absolute path of the theme root to look in. If not specified, get_raw_theme_root() is used to calculate the theme root for the $stylesheet provided (or active theme).Default:
''
Return
WP_Theme- Theme object. Be sure to check the object's exists() method if you need to confirm the theme's existence.
Uses · 3
- get_stylesheet()Retrieves name of the current stylesheet.
- get_raw_theme_root()Gets the raw theme root relative to the content directory with no filters applied.
- WP_Theme::__construct()Constructor for WP_Theme.
Used by · 50
- Language_Pack_Upgrader::get_name_for_update()Gets the name of an item being updated.
- Theme_Upgrader::theme_info()Gets the WP_Theme object for a theme.
- Twenty_Twenty_One_Custom_Colors::editor_custom_color_variables()Editor custom color variables.
- Twenty_Twenty_One_Customize_Color_Control::enqueue()Enqueues control related scripts/styles.
- Twenty_Twenty_One_Dark_Mode::customize_controls_enqueue_scripts()Enqueues scripts for the customizer.
- Twenty_Twenty_One_Dark_Mode::editor_custom_color_variables()Enqueues editor custom color variables & scripts.
- Twenty_Twenty_One_Dark_Mode::enqueue_scripts()Enqueues scripts and styles.
- WP_Automatic_Updater::update()Updates an item, if appropriate.
- WP_Customize_Manager::__construct()Constructor.
- WP_Customize_Manager::theme()Gets the theme being customized.
- WP_Debug_Data::get_wp_active_theme()Gets the WordPress active theme section of the debug data.
- WP_Debug_Data::get_wp_parent_theme()Gets the WordPress parent theme section of the debug data.
Show all 50
- WP_Debug_Data::get_wp_themes_inactive()Gets the WordPress inactive themes section of the debug data.
- WP_REST_Posts_Controller::check_template()Checks whether the template is valid for the given post.
- WP_REST_Posts_Controller::handle_template()Sets the template for a post.
- WP_REST_Server::add_active_theme_link_to_index()Adds a link to the active theme for users who have proper permissions.
- WP_REST_Templates_Controller::get_wp_templates_author_text_field()Returns a human readable text for the author of the template.
- WP_REST_Themes_Controller::get_item()Retrieves a single theme.
- WP_REST_Themes_Controller::get_item_permissions_check()Checks if a given request has access to read the theme.
- WP_REST_Themes_Controller::get_items()Retrieves a collection of themes.
- WP_REST_Themes_Controller::prepare_item_for_response()Prepares a single theme output for response.
- WP_REST_Themes_Controller::prepare_links()Prepares links for the request.
- WP_Recovery_Mode_Email_Service::get_cause()Gets the description indicating the possible cause for the error.
- WP_Recovery_Mode_Email_Service::get_debug()Return debug information in an easy to manipulate format.
- WP_Site_Health::get_test_theme_version()Tests if themes are outdated, or unnecessary.
- WP_Theme::get_core_default_theme()Determines the latest WordPress default theme that is installed.
- WP_Theme_Install_List_Table::_get_theme_status()Checks to see if the theme is already installed.
- WP_Theme_JSON_Resolver::get_style_variations()Returns the style variations defined by the theme.
- WP_Theme_JSON_Resolver::get_theme_data()Returns the theme's data.
- WP_Theme_JSON_Resolver::get_user_data()Returns the user's origin config.
- WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles()Returns the custom post type that contains the user's origin config for the active theme or an empty array if none are found.
- WP_Theme_JSON_Resolver::get_user_global_styles_post_id()Returns the ID of the custom post type that stores user data.
- _register_theme_block_patterns()Register any patterns that the active theme may provide under its `./patterns/` directory.
- check_theme_switched()Checks if a theme has been changed and runs 'after_switch_theme' hook on the next WP load.
- current_theme_info()Retrieves information on the current active theme.
- delete_theme()Removes a theme.
- get_block_theme_folders()For backward compatibility reasons, block themes might be using block-templates or block-template-parts, this function ensures we fallback to these folders properly.
- get_current_theme()Retrieve current theme name.
- get_page_templates()Gets the page templates available in this theme.
- get_theme_mods()Retrieves all theme modifications.
- get_theme_updates()Retrieves themes with updates available.
- populate_network_meta()Creates WordPress network meta and sets the default values.
- populate_options()Create WordPress options and set the default values.
- remove_theme_mods()Removes theme modifications option for the active theme.
- switch_theme()Switches the theme.
- twenty_twenty_one_scripts()Enqueues scripts and styles.
- twentyeleven_theme_options_render_page()Renders the theme options page for Twenty Eleven.
- twentynineteen_scripts()Enqueues scripts and styles.
- twentytwenty_block_editor_styles()Enqueues supplemental block editor styles.
- twentytwenty_customize_controls_enqueue_scripts()Enqueues scripts for customizer controls & settings.
Source
function wp_get_theme( $stylesheet = '', $theme_root = '' ) { global $wp_theme_directories; if ( empty( $stylesheet ) ) { $stylesheet = get_stylesheet(); } if ( empty( $theme_root ) ) { $theme_root = get_raw_theme_root( $stylesheet ); if ( false === $theme_root ) { $theme_root = WP_CONTENT_DIR . '/themes'; } elseif ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) { $theme_root = WP_CONTENT_DIR . $theme_root; } } return new WP_Theme( $stylesheet, $theme_root );}History
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/theme.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.