Skip to content

Instantly share code, notes, and snippets.

@cubehrends
Last active October 9, 2017 08:52
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 cubehrends/a7adf3aaf54a9036b54c64139565ee8a to your computer and use it in GitHub Desktop.
Save cubehrends/a7adf3aaf54a9036b54c64139565ee8a to your computer and use it in GitHub Desktop.
<?php
function event_pre_get_posts( $query ) {
// modify queries for 'event' post type only
if( isset( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] == 'event' ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'eventdetails_eventday_1');
$query->set('order', 'ASC');
}
return $query;
}
add_action('pre_get_posts', 'event_pre_get_posts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment