# wp_get_themes()

URL: https://chugunov.pro/api-wordpress/functions/wp_get_themes/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.4.0.

## Сигнатура

```php
wp_get_themes( array $args = array() ): WP_Theme[]
```

## Описание

Несмотря на улучшения по сравнению с get_themes() , эта функция довольно ресурсоёмка, и её стоимость растёт линейно с добавлением тем. По возможности используйте wp_get_theme() .

## Параметры

- `$args` `array` — необязательный, по умолчанию `array()`. Аргументы поиска.
  
  errors mixedTrue — вернуть темы с ошибками, false — вернуть темы без ошибок, null — вернуть все темы.
  
  По умолчанию false.
  
  allowed mixed(Мультисайт) True — вернуть только разрешённые темы для сайта.
  
  False — вернуть только запрещённые темы для сайта.
  
  'site' — вернуть только темы, разрешённые для сайта.
  
  'network' — вернуть только темы, разрешённые для сети.
  
  Null — вернуть все темы. По умолчанию null.
  
  blog_id int(Мультисайт) Идентификатор блога, используемый для расчёта того, какие темы разрешены. По умолчанию 0, что соответствует текущему блогу.

## Возвращаемое значение

`WP_Theme[]` — WP_Theme

## Исходный код

Файл: `wp-includes/theme.php:35`

```php
function wp_get_themes( $args = array() ) {
	global $wp_theme_directories;

	$defaults = array(
		'errors'  => false,
		'allowed' => null,
		'blog_id' => 0,
	);
	$args     = wp_parse_args( $args, $defaults );

	$theme_directories = search_theme_directories();

	if ( is_array( $wp_theme_directories ) && count( $wp_theme_directories ) > 1 ) {
		/*
		 * Make sure the active theme wins out, in case search_theme_directories() picks the wrong
		 * one in the case of a conflict. (Normally, last registered theme root wins.)
		 */
		$current_theme = get_stylesheet();
		if ( isset( $theme_directories[ $current_theme ] ) ) {
			$root_of_current_theme = get_raw_theme_root( $current_theme );
			if ( ! in_array( $root_of_current_theme, $wp_theme_directories, true ) ) {
				$root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
			}
			$theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;
		}
	}

	if ( empty( $theme_directories ) ) {
		return array();
	}

	if ( is_multisite() && null !== $args['allowed'] ) {
		$allowed = $args['allowed'];
		if ( 'network' === $allowed ) {
			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_network() );
		} elseif ( 'site' === $allowed ) {
			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_site( $args['blog_id'] ) );
		} elseif ( $allowed ) {
			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
		} else {
			$theme_directories = array_diff_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
		}
	}

	$themes         = array();
	static $_themes = array();

	foreach ( $theme_directories as $theme => $theme_root ) {
		if ( isset( $_themes[ $theme_root['theme_root'] . '/' . $theme ] ) ) {
			$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ];
		} else {
			$themes[ $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] );

			$_themes[ $theme_root['theme_root'] . '/' . $theme ] = $themes[ $theme ];
		}
	}

	if ( null !== $args['errors'] ) {
		foreach ( $themes as $theme => $wp_theme ) {
			if ( (bool) $wp_theme->errors() !== $args['errors'] ) {
				unset( $themes[ $theme ] );
			}
		}
	}

	return $themes;
}
```

## История изменений

- 3.4.0 — Introduced.

## Связанные

Использует: [`get_raw_theme_root`](https://chugunov.pro/api-wordpress/functions/get_raw_theme_root/), [`search_theme_directories`](https://chugunov.pro/api-wordpress/functions/search_theme_directories/), [`get_stylesheet`](https://chugunov.pro/api-wordpress/functions/get_stylesheet/), `WP_Theme::get_allowed_on_network`, `WP_Theme::get_allowed_on_site`, `WP_Theme::get_allowed`, `WP_Theme::errors`, `WP_Theme::__construct`, `WP_Theme`, [`is_multisite`](https://chugunov.pro/api-wordpress/functions/is_multisite/), [`wp_parse_args`](https://chugunov.pro/api-wordpress/functions/wp_parse_args/).
Используется в: `WP_Debug_Data::get_wp_themes_inactive`, `Theme_Installer_Skin::do_overwrite`, [`wp_ajax_toggle_auto_updates`](https://chugunov.pro/api-wordpress/functions/wp_ajax_toggle_auto_updates/), `WP_Site_Health::get_test_theme_version`, `WP_REST_Themes_Controller::get_items`, `WP_Customize_Manager::handle_load_themes_request`, [`wp_prepare_themes_for_js`](https://chugunov.pro/api-wordpress/functions/wp_prepare_themes_for_js/), [`get_allowed_themes`](https://chugunov.pro/api-wordpress/functions/get_allowed_themes/), [`get_broken_themes`](https://chugunov.pro/api-wordpress/functions/get_broken_themes/), `WP_MS_Themes_List_Table::prepare_items`, [`upgrade_network`](https://chugunov.pro/api-wordpress/functions/upgrade_network/), `WP_Themes_List_Table::prepare_items`, [`wp_clean_themes_cache`](https://chugunov.pro/api-wordpress/functions/wp_clean_themes_cache/), [`get_theme_roots`](https://chugunov.pro/api-wordpress/functions/get_theme_roots/), `WP_Theme`, [`get_themes`](https://chugunov.pro/api-wordpress/functions/get_themes/), `WP_Theme::get_allowed_on_site`, [`wp_update_themes`](https://chugunov.pro/api-wordpress/functions/wp_update_themes/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_get_themes/
