Last active
March 8, 2016 08:08
-
-
Save ms-studio/1c0ee763d1c71a05b114 to your computer and use it in GitHub Desktop.
About page-schedule-grid for LGM
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
<?php | |
/* | |
* 1) Use transient for better performance: | |
* | |
* Instead of this: | |
*/ | |
$custom_query = new WP_Query(array( | |
'post_type' => 'talk', | |
'post_status' => 'any', | |
'posts_per_page' => -1, | |
// 'orderby' => 'date', | |
'orderby' => 'meta_value', | |
'meta_key' => '_mem_start_date', | |
'order' => 'ASC', | |
)); | |
/* | |
* We can do this: | |
*/ | |
if ( false === ( $custom_query = get_transient( 'lgm16_schedule_grid' ) ) ) { | |
// It wasn't there, so regenerate the data and save the transient | |
$custom_query = new WP_Query(array( | |
'post_type' => 'talk', | |
'post_status' => 'any', | |
'posts_per_page' => -1, | |
// 'orderby' => 'date', | |
'orderby' => 'meta_value', | |
'meta_key' => '_mem_start_date', | |
'order' => 'ASC', | |
)); | |
set_transient( 'lgm16_schedule_grid', $custom_query, 12 * HOUR_IN_SECONDS ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment