In my custom post type, I have 2 custom fields:
- iso_flag (= iso codes like be, us, ...)
- ranking (1, 2, ...)
I want to write a WP Query, that first orders by 'iso_flag' (alphabetical) and secondly orders by ranking (numeric). How can I achieve that?
This is what I have so far:
$args = array(
'post_type' => 'commission_member',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'commission_member_category',
'field' => 'term_taxonomy_id',
'terms' => $commission_category
)
),
'country_clause' => array(
'meta_key' => 'iso_flag',
'orderby' => 'meta_value',
),
'ranking_clause' => array(
'meta_key' => 'ranking',
'orderby' => 'meta_value_num',
),
'orderby' => array(
'country_clause' => 'DESC',
'ranking_clause' => 'ASC'
)
);