Codex tools: Log in
Contents |
Get the value of a transient.
If the transient does not exist or does not have a value, then the return value will be false.
<?php get_transient( $transient ); ?>
<?php
// Get any existing copy of our transient data
if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$special_query_results = new WP_Query( 'cat=5&order=random&tag=tech&post_meta_key=thumbnail' );
set_transient( 'special_query_results', $special_query_results );
}
// Use the data like you would have normally...
?>
Since: 2.8
get_transient() is located in wp-includes/option.php.
Transients API: set_transient(), get_transient(), delete_transient(), set_site_transient(), get_site_transient(), delete_site_transient()