# get_transient()

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

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

## Сигнатура

```php
get_transient( string $transient ): mixed
```

## Описание

Если транзиент не существует, не имеет значения или его срок истёк, возвращаемым значением будет false.

## Параметры

- `$transient` `string` — обязательный. Имя транзиента. Ожидается, что не экранировано для SQL.

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

`mixed`

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

Файл: `wp-includes/option.php:1429`

```php
function get_transient( $transient ) {

	/**
	 * Filters the value of an existing transient before it is retrieved.
	 *
	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
	 *
	 * Returning a value other than false from the filter will short-circuit retrieval
	 * and return that value instead.
	 *
	 * @since 2.8.0
	 * @since 4.4.0 The `$transient` parameter was added
	 *
	 * @param mixed  $pre_transient The default value to return if the transient does not exist.
	 *                              Any value other than false will short-circuit the retrieval
	 *                              of the transient, and return that value.
	 * @param string $transient     Transient name.
	 */
	$pre = apply_filters( "pre_transient_{$transient}", false, $transient );

	if ( false !== $pre ) {
		return $pre;
	}

	if ( wp_using_ext_object_cache() || wp_installing() ) {
		$value = wp_cache_get( $transient, 'transient' );
	} else {
		$transient_option = '_transient_' . $transient;
		if ( ! wp_installing() ) {
			// If option is not in alloptions, it is not autoloaded and thus has a timeout.
			$alloptions = wp_load_alloptions();

			if ( ! isset( $alloptions[ $transient_option ] ) ) {
				$transient_timeout = '_transient_timeout_' . $transient;
				wp_prime_option_caches( array( $transient_option, $transient_timeout ) );
				$timeout = get_option( $transient_timeout );
				if ( false !== $timeout && $timeout < time() ) {
					delete_option( $transient_option );
					delete_option( $transient_timeout );
					$value = false;
				}
			}
		}

		if ( ! isset( $value ) ) {
			$value = get_option( $transient_option );
		}
	}

	/**
	 * Filters an existing transient's value.
	 *
	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
	 *
	 * @since 2.8.0
	 * @since 4.4.0 The `$transient` parameter was added
	 *
	 * @param mixed  $value     Value of transient.
	 * @param string $transient Transient name.
	 */
	return apply_filters( "transient_{$transient}", $value, $transient );
}
```

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

- 2.8.0 — Introduced.

## Связанные

Использует: [`wp_prime_option_caches`](https://chugunov.pro/api-wordpress/functions/wp_prime_option_caches/), [`wp_installing`](https://chugunov.pro/api-wordpress/functions/wp_installing/), [`wp_using_ext_object_cache`](https://chugunov.pro/api-wordpress/functions/wp_using_ext_object_cache/), [`wp_load_alloptions`](https://chugunov.pro/api-wordpress/functions/wp_load_alloptions/), [`delete_option`](https://chugunov.pro/api-wordpress/functions/delete_option/), [`wp_cache_get`](https://chugunov.pro/api-wordpress/functions/wp_cache_get/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: [`wp_add_global_styles_for_blocks`](https://chugunov.pro/api-wordpress/functions/wp_add_global_styles_for_blocks/), [`clean_dirsize_cache`](https://chugunov.pro/api-wordpress/functions/clean_dirsize_cache/), [`recurse_dirsize`](https://chugunov.pro/api-wordpress/functions/recurse_dirsize/), [`wp_dashboard_site_health`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_site_health/), `WP_Site_Health::enqueue_scripts`, [`wp_start_scraping_edited_file_errors`](https://chugunov.pro/api-wordpress/functions/wp_start_scraping_edited_file_errors/), `WP_oEmbed_Controller::get_proxy_item`, [`install_themes_feature_list`](https://chugunov.pro/api-wordpress/functions/install_themes_feature_list/), [`wp_dashboard_cached_rss_widget`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_cached_rss_widget/), [`wp_dashboard_plugins_output`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_plugins_output/), [`get_settings_errors`](https://chugunov.pro/api-wordpress/functions/get_settings_errors/), [`add_settings_error`](https://chugunov.pro/api-wordpress/functions/add_settings_error/), [`spawn_cron`](https://chugunov.pro/api-wordpress/functions/spawn_cron/), [`wp_rand`](https://chugunov.pro/api-wordpress/functions/wp_rand/), [`wp_maybe_generate_attachment_metadata`](https://chugunov.pro/api-wordpress/functions/wp_maybe_generate_attachment_metadata/), [`is_multi_author`](https://chugunov.pro/api-wordpress/functions/is_multi_author/), `RSSCache::get`, `RSSCache::check_cache`.

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