Created
October 22, 2015 00:17
-
-
Save sdunham/255bb0d7558401fe2182 to your computer and use it in GitHub Desktop.
Caching With WordPress Transients
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get any existing copy of our transient data, if one exists | |
if ( false === ( $foo = get_transient( 'foo_transient' ) ) ) { | |
// Nothing found, or transient expired. Regenerate it! | |
$foo = someExpensiveCodeOrQuery(); | |
set_transient( 'foo_transient', $foo, 2*HOUR_IN_SECONDS ); | |
} | |
// Use $foo somehow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment