WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know if there is a Wordpress function to get the timeout value of a saved transient? I am using a transient with a 5 minute timeout to cache data from a web API call locally. Between transient timeouts I load the data locally from the transient acting as a cache and secondary API throttle. What I would like to do is read and display the timeout value of the currently saved transient data so the user knows how long they need to wait before the next data refresh. The value is stored in the 'wp_options' table as '_transient_timeout_transient-name', so I assume I could use the global $wpdb object and just do a SQL query, but I wanted to make sure there wasn't a more elegant way.

share|improve this question
up vote 2 down vote accepted

So, after one minute of more thinking, there is an easy solution, although i did not try it myself:

$transient = '_transient_timeout_' . $_your_transient_name;
$transient_timeout = get_option ( $transient );

you should be ready to go with this.

Another Way throught the database would be:

$transient = '_transient_timeout_' . $_your_transient_name;

global $wpdb;

$query = 'SELECT option_value FROM ' . $wpdb->prefix . 'options WHERE option_name = ' . $transient;

$transient_timeout = $wpdb->get_var( $wpdb->prepare( $query ) );

the returned value is a timestamp, but i'm sure you know how to handle it from here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.