Last active
October 31, 2016 14:57
-
-
Save infoscigeek/1e4a5fbbd48a109d28eebc710ce89e73 to your computer and use it in GitHub Desktop.
How to orderby using multiple custom fields / meta values
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
<? | |
//How to orderby using multiple meta values | |
$query = new WP_Query( | |
array( | |
'post_type' => 'sessions', | |
'posts_per_page' => -1, | |
'meta_query' => array( | |
'relation' => 'AND', | |
'hour_clause' => array( | |
'key' => 'start_hour', | |
'compare' => 'EXISTS', | |
), | |
'min_clause' => array( | |
'key' => 'start_min', | |
'compare' => 'EXISTS', | |
), | |
), | |
'orderby' => array( | |
'hour_clause' => 'ASC', | |
'min_clause' => 'ASC', | |
), | |
) | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment