Skip to content

Instantly share code, notes, and snippets.

@infoscigeek
Last active October 31, 2016 14:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infoscigeek/1e4a5fbbd48a109d28eebc710ce89e73 to your computer and use it in GitHub Desktop.
Save infoscigeek/1e4a5fbbd48a109d28eebc710ce89e73 to your computer and use it in GitHub Desktop.
How to orderby using multiple custom fields / meta values
<?
//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