# register_theme_directory()

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

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

## Сигнатура

```php
register_theme_directory( string $directory ): bool
```

## Описание

Регистрирует каталог, содержащий темы.

## Параметры

- `$directory` `string` — обязательный. Либо полный путь в файловой системе к папке темы, либо папка внутри WP_CONTENT_DIR.

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

`bool`

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

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

```php
function register_theme_directory( $directory ) {
	global $wp_theme_directories;

	if ( ! file_exists( $directory ) ) {
		// Try prepending as the theme directory could be relative to the content directory.
		$directory = WP_CONTENT_DIR . '/' . $directory;
		// If this directory does not exist, return and do not register.
		if ( ! file_exists( $directory ) ) {
			return false;
		}
	}

	if ( ! is_array( $wp_theme_directories ) ) {
		$wp_theme_directories = array();
	}

	$untrailed = untrailingslashit( $directory );
	if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories, true ) ) {
		$wp_theme_directories[] = $untrailed;
	}

	return true;
}
```

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

- 2.9.0 — Introduced.

## Связанные

Использует: [`untrailingslashit`](https://chugunov.pro/api-wordpress/functions/untrailingslashit/).

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