Title: set_site_transient
Published: April 25, 2014
Last modified: February 24, 2026

---

# set_site_transient( string $transient, mixed $value, int $expiration ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#wp--skip-link--target)

Sets/updates the value of a site transient.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#description)󠁿

You do not need to serialize values. If the value needs to be serialized, then it
will be serialized before it is set.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#see-also)󠁿

 * [set_transient()](https://developer.wordpress.org/reference/functions/set_transient/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#parameters)󠁿

 `$transient`stringrequired

Transient name. Expected to not be SQL-escaped. Must be 167 characters or fewer 
in length.

`$value`mixedrequired

Transient value. Expected to not be SQL-escaped.

`$expiration`intoptional

Time until expiration in seconds. Default 0 (no expiration).

## 󠀁[Return](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#return)󠁿

 bool True if the value was set, false otherwise.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#source)󠁿

    ```php
    function set_site_transient( $transient, $value, $expiration = 0 ) {

    	/**
    	 * Filters the value of a specific site transient before it is set.
    	 *
    	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
    	 *
    	 * @since 3.0.0
    	 * @since 4.4.0 The `$transient` parameter was added.
    	 *
    	 * @param mixed  $value     New value of site transient.
    	 * @param string $transient Transient name.
    	 */
    	$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );

    	$expiration = (int) $expiration;

    	/**
    	 * Filters the expiration for a site transient before its value is set.
    	 *
    	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
    	 *
    	 * @since 4.4.0
    	 *
    	 * @param int    $expiration Time until expiration in seconds. Use 0 for no expiration.
    	 * @param mixed  $value      New value of site transient.
    	 * @param string $transient  Transient name.
    	 */
    	$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );

    	if ( wp_using_ext_object_cache() || wp_installing() ) {
    		$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
    	} else {
    		$transient_timeout = '_site_transient_timeout_' . $transient;
    		$option            = '_site_transient_' . $transient;
    		wp_prime_site_option_caches( array( $option, $transient_timeout ) );

    		if ( false === get_site_option( $option ) ) {
    			if ( $expiration ) {
    				add_site_option( $transient_timeout, time() + $expiration );
    			}
    			$result = add_site_option( $option, $value );
    		} else {
    			if ( $expiration ) {
    				update_site_option( $transient_timeout, time() + $expiration );
    			}
    			$result = update_site_option( $option, $value );
    		}
    	}

    	if ( $result ) {

    		/**
    		 * Fires after the value for a specific site transient has been set.
    		 *
    		 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
    		 *
    		 * @since 3.0.0
    		 * @since 4.4.0 The `$transient` parameter was added
    		 *
    		 * @param mixed  $value      Site transient value.
    		 * @param int    $expiration Time until expiration in seconds.
    		 * @param string $transient  Transient name.
    		 */
    		do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );

    		/**
    		 * Fires after the value for a site transient has been set.
    		 *
    		 * @since 6.8.0
    		 *
    		 * @param string $transient  The name of the site transient.
    		 * @param mixed  $value      Site transient value.
    		 * @param int    $expiration Time until expiration in seconds.
    		 */
    		do_action( 'set_site_transient', $transient, $value, $expiration );

    		/**
    		 * Fires after the value for a site transient has been set.
    		 *
    		 * @since 3.0.0
    		 * @deprecated 6.8.0 Use 'set_site_transient' instead.
    		 *
    		 * @param string $transient  The name of the site transient.
    		 * @param mixed  $value      Site transient value.
    		 * @param int    $expiration Time until expiration in seconds.
    		 */
    		do_action_deprecated( 'setted_site_transient', array( $transient, $value, $expiration ), '6.8.0', 'set_site_transient' );
    	}

    	return $result;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/option.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/option.php#L2641)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/option.php#L2641-L2732)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#hooks)󠁿

 [apply_filters( “expiration_of_site_transient_{$transient}”, int $expiration, mixed $value, string $transient )](https://developer.wordpress.org/reference/hooks/expiration_of_site_transient_transient/)

Filters the expiration for a site transient before its value is set.

 [apply_filters( “pre_set_site_transient_{$transient}”, mixed $value, string $transient )](https://developer.wordpress.org/reference/hooks/pre_set_site_transient_transient/)

Filters the value of a specific site transient before it is set.

 [do_action_deprecated( ‘setted_site_transient’, string $transient, mixed $value, int $expiration )](https://developer.wordpress.org/reference/hooks/setted_site_transient/)

Fires after the value for a site transient has been set.

 [do_action( ‘set_site_transient’, string $transient, mixed $value, int $expiration )](https://developer.wordpress.org/reference/hooks/set_site_transient/)

Fires after the value for a site transient has been set.

 [do_action( “set_site_transient_{$transient}”, mixed $value, int $expiration, string $transient )](https://developer.wordpress.org/reference/hooks/set_site_transient_transient/)

Fires after the value for a specific site transient has been set.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_prime_site_option_caches()](https://developer.wordpress.org/reference/functions/wp_prime_site_option_caches/)`wp-includes/option.php` |

Primes specific network options for the current network into the cache with a single database query.

  | 
| [do_action_deprecated()](https://developer.wordpress.org/reference/functions/do_action_deprecated/)`wp-includes/plugin.php` |

Fires functions attached to a deprecated action hook.

  | 
| [wp_installing()](https://developer.wordpress.org/reference/functions/wp_installing/)`wp-includes/load.php` |

Checks or sets whether WordPress is in “installation” mode.

  | 
| [wp_cache_set()](https://developer.wordpress.org/reference/functions/wp_cache_set/)`wp-includes/cache.php` |

Saves the data to the cache.

  | 
| [wp_using_ext_object_cache()](https://developer.wordpress.org/reference/functions/wp_using_ext_object_cache/)`wp-includes/load.php` |

Toggles `$_wp_using_ext_object_cache` on and off without directly touching global.

  | 
| [add_site_option()](https://developer.wordpress.org/reference/functions/add_site_option/)`wp-includes/option.php` |

Adds a new option for the current network.

  | 
| [update_site_option()](https://developer.wordpress.org/reference/functions/update_site_option/)`wp-includes/option.php` |

Updates the value of an option that was already added for the current network.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [get_site_option()](https://developer.wordpress.org/reference/functions/get_site_option/)`wp-includes/option.php` |

Retrieve an option value for the current network based on name of option.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#)

| Used by | Description | 
| [WP_Plugin_Dependencies::get_dependency_api_data()](https://developer.wordpress.org/reference/classes/wp_plugin_dependencies/get_dependency_api_data/)`wp-includes/class-wp-plugin-dependencies.php` |

Retrieves and stores dependency plugin data from the WordPress.org Plugin API.

  | 
| [WP_Font_Collection::load_from_url()](https://developer.wordpress.org/reference/classes/wp_font_collection/load_from_url/)`wp-includes/fonts/class-wp-font-collection.php` |

Loads the font collection data from a JSON file URL.

  | 
| [WP_Theme::set_pattern_cache()](https://developer.wordpress.org/reference/classes/wp_theme/set_pattern_cache/)`wp-includes/class-wp-theme.php` |

Sets block pattern cache.

  | 
| [WP_REST_URL_Details_Controller::set_cache()](https://developer.wordpress.org/reference/classes/wp_rest_url_details_controller/set_cache/)`wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php` |

Utility function to cache a given data set at a given cache key.

  | 
| [WP_REST_Pattern_Directory_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php` |

Search and retrieve block patterns metadata

  | 
| [wp_check_php_version()](https://developer.wordpress.org/reference/functions/wp_check_php_version/)`wp-admin/includes/misc.php` |

Checks if the user needs to update PHP.

  | 
| [WP_Community_Events::cache_events()](https://developer.wordpress.org/reference/classes/wp_community_events/cache_events/)`wp-admin/includes/class-wp-community-events.php` |

Caches an array of events data from the Events API.

  | 
| [wp_get_available_translations()](https://developer.wordpress.org/reference/functions/wp_get_available_translations/)`wp-admin/includes/translation-install.php` |

Get available translations from the WordPress.org API.

  | 
| [get_theme_feature_list()](https://developer.wordpress.org/reference/functions/get_theme_feature_list/)`wp-admin/includes/theme.php` |

Retrieves list of WordPress theme features (aka theme tags).

  | 
| [wp_check_browser_version()](https://developer.wordpress.org/reference/functions/wp_check_browser_version/)`wp-admin/includes/dashboard.php` |

Checks if the user needs a browser update.

  | 
| [install_popular_tags()](https://developer.wordpress.org/reference/functions/install_popular_tags/)`wp-admin/includes/plugin-install.php` |

Retrieves popular WordPress plugin tags.

  | 
| [delete_plugins()](https://developer.wordpress.org/reference/functions/delete_plugins/)`wp-admin/includes/plugin.php` |

Removes directory and files of a plugin for a list of plugins.

  | 
| [wp_get_popular_importers()](https://developer.wordpress.org/reference/functions/wp_get_popular_importers/)`wp-admin/includes/import.php` |

Returns a list from WordPress.org of popular importer plugins.

  | 
| [wp_credits()](https://developer.wordpress.org/reference/functions/wp_credits/)`wp-admin/includes/credits.php` |

Retrieves the contributor credits.

  | 
| [search_theme_directories()](https://developer.wordpress.org/reference/functions/search_theme_directories/)`wp-includes/theme.php` |

Searches all registered theme directories for complete and valid themes.

  | 
| [WP_Feed_Cache_Transient::save()](https://developer.wordpress.org/reference/classes/wp_feed_cache_transient/save/)`wp-includes/class-wp-feed-cache-transient.php` |

Saves data to the transient.

  | 
| [WP_Feed_Cache_Transient::touch()](https://developer.wordpress.org/reference/classes/wp_feed_cache_transient/touch/)`wp-includes/class-wp-feed-cache-transient.php` |

Sets mod transient.

  | 
| [wp_version_check()](https://developer.wordpress.org/reference/functions/wp_version_check/)`wp-includes/update.php` |

Checks WordPress version against the newest version.

  | 
| [wp_update_plugins()](https://developer.wordpress.org/reference/functions/wp_update_plugins/)`wp-includes/update.php` |

Checks for available updates to plugins based on the latest versions hosted on WordPress.org.

  | 
| [wp_update_themes()](https://developer.wordpress.org/reference/functions/wp_update_themes/)`wp-includes/update.php` |

Checks for available updates to themes based on the latest versions hosted on WordPress.org.

  |

[Show 15 more](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/set_site_transient/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fset_site_transient%2F)
before being able to contribute a note or feedback.