Skip to content

Instantly share code, notes, and snippets.

@ms-studio
Last active March 8, 2016 08:08
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 ms-studio/1c0ee763d1c71a05b114 to your computer and use it in GitHub Desktop.
Save ms-studio/1c0ee763d1c71a05b114 to your computer and use it in GitHub Desktop.
About page-schedule-grid for LGM
<?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