Skip to content

Instantly share code, notes, and snippets.

@Robzelf
Last active March 16, 2017 13:06
Show Gist options
  • Save Robzelf/21555c872d72ff8273eb3908757a9dcb to your computer and use it in GitHub Desktop.
Save Robzelf/21555c872d72ff8273eb3908757a9dcb to your computer and use it in GitHub Desktop.
Sort query by multiple keys
function update_archive( $query ) {
$query->set('meta_query' , array(
'day_clause' => array( 'key' => 'event__day' ),
'time_clause' => array( 'key' => 'event__start_time' )));
$query->set('orderby' , array( 'day_clause' => 'ASC', 'time_clause' => 'ASC' ));
}
add_action( 'pre_get_posts', 'update_archive' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment