# _get_random_header_data()

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

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

## Сигнатура

```php
_get_random_header_data(): object
```

## Описание

Получает данные случайного изображения заголовка из зарегистрированных в теме изображений.

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

`object`

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

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

```php
function _get_random_header_data() {
	global $_wp_default_headers;
	static $_wp_random_header = null;

	if ( empty( $_wp_random_header ) ) {
		$header_image_mod = get_theme_mod( 'header_image', '' );
		$headers          = array();

		if ( 'random-uploaded-image' === $header_image_mod ) {
			$headers = get_uploaded_header_images();
		} elseif ( ! empty( $_wp_default_headers ) ) {
			if ( 'random-default-image' === $header_image_mod ) {
				$headers = $_wp_default_headers;
			} else {
				if ( current_theme_supports( 'custom-header', 'random-default' ) ) {
					$headers = $_wp_default_headers;
				}
			}
		}

		if ( empty( $headers ) ) {
			return new stdClass();
		}

		$_wp_random_header = (object) $headers[ array_rand( $headers ) ];

		$_wp_random_header->url = sprintf(
			$_wp_random_header->url,
			get_template_directory_uri(),
			get_stylesheet_directory_uri()
		);

		$_wp_random_header->thumbnail_url = sprintf(
			$_wp_random_header->thumbnail_url,
			get_template_directory_uri(),
			get_stylesheet_directory_uri()
		);
	}

	return $_wp_random_header;
}
```

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

- 3.4.0 — Introduced.

## Связанные

Использует: [`get_uploaded_header_images`](https://chugunov.pro/api-wordpress/functions/get_uploaded_header_images/), [`get_theme_mod`](https://chugunov.pro/api-wordpress/functions/get_theme_mod/), [`get_template_directory_uri`](https://chugunov.pro/api-wordpress/functions/get_template_directory_uri/), [`get_stylesheet_directory_uri`](https://chugunov.pro/api-wordpress/functions/get_stylesheet_directory_uri/), [`current_theme_supports`](https://chugunov.pro/api-wordpress/functions/current_theme_supports/).
Используется в: [`get_random_header_image`](https://chugunov.pro/api-wordpress/functions/get_random_header_image/), [`get_custom_header`](https://chugunov.pro/api-wordpress/functions/get_custom_header/).

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