Skip to content

Instantly share code, notes, and snippets.

@ernilambar
Last active July 17, 2017 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ernilambar/abf3b77c3a0f5599d7ab to your computer and use it in GitHub Desktop.
Save ernilambar/abf3b77c3a0f5599d7ab to your computer and use it in GitHub Desktop.
WordPress Transient Example
<?php
function example_transient(){
$transient_key = 'my_unique_transient_key';
$transient_period = 24 * HOUR_IN_SECONDS;
$output = get_transient( $transient_key );
if ( false === $output ) {
$output = 'Hello World';
set_transient( $transient_key, $output, $transient_period );
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment