Skip to content

Instantly share code, notes, and snippets.

@ihorvorotnov
Created February 21, 2014 11:28
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 ihorvorotnov/9132748 to your computer and use it in GitHub Desktop.
Save ihorvorotnov/9132748 to your computer and use it in GitHub Desktop.
WordPress: caching custom queries
// 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( '_YOUR_QUERY_ARGS_HERE_' );
set_transient( 'special_query_results', $special_query_results );
}
// 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