Created
February 21, 2014 11:28
-
-
Save ihorvorotnov/9132748 to your computer and use it in GitHub Desktop.
WordPress: caching custom queries
This file contains hidden or 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 ( 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