# is_random_header_image()

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

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

## Сигнатура

```php
is_random_header_image( string $type = 'any' ): bool
```

## Описание

Всегда true, если пользователь явно выбирает эту опцию в разделе «Внешний вид → Заголовок».
Также true, если в теме зарегистрировано несколько изображений заголовка, конкретное изображение не выбрано, а тема включает случайные заголовки с помощью add_theme_support().

## Параметры

- `$type` `string` — необязательный, по умолчанию `'any'`. Пул случайных изображений для использования. Возможные значения: 'any', 'default', 'uploaded'. Значение по умолчанию — 'any'.

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

`bool`

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

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

```php
function is_random_header_image( $type = 'any' ) {
	$header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );

	if ( 'any' === $type ) {
		if ( 'random-default-image' === $header_image_mod
			|| 'random-uploaded-image' === $header_image_mod
			|| ( empty( $header_image_mod ) && '' !== get_random_header_image() )
		) {
			return true;
		}
	} else {
		if ( "random-$type-image" === $header_image_mod ) {
			return true;
		} elseif ( 'default' === $type
			&& empty( $header_image_mod ) && '' !== get_random_header_image()
		) {
			return true;
		}
	}

	return false;
}
```

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

- 3.2.0 — Introduced.

## Связанные

Использует: [`get_theme_support`](https://chugunov.pro/api-wordpress/functions/get_theme_support/), [`get_random_header_image`](https://chugunov.pro/api-wordpress/functions/get_random_header_image/), [`get_theme_mod`](https://chugunov.pro/api-wordpress/functions/get_theme_mod/).
Используется в: [`get_media_states`](https://chugunov.pro/api-wordpress/functions/get_media_states/), `Custom_Image_Header::show_header_selector`, [`get_header_image`](https://chugunov.pro/api-wordpress/functions/get_header_image/), [`get_custom_header`](https://chugunov.pro/api-wordpress/functions/get_custom_header/).

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