Skip to content

Instantly share code, notes, and snippets.

@alexandrascript
Last active August 29, 2015 14:20
Show Gist options
  • Save alexandrascript/1aa752722956eb72ea9d to your computer and use it in GitHub Desktop.
Save alexandrascript/1aa752722956eb72ea9d to your computer and use it in GitHub Desktop.
WP Transients - Get Transient Data
// 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, 12 * HOUR_IN_SECONDS );
}
// Use the data like you would have normally...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment