order the meta query results by 2 custom fields
I have a custom post type 'brewery', I want to fetch results by 2 custom fields. The desired result is to get all posts with highest review rating (value is in decimal like 4.2 or 4.8) and if few posts have same review rating then I want to sort the results by review count (value is numeric and can be any number like 5, 400 or even 2500).
Example:
Post 1 - Review rating = 4.8 Review Count = 2500
Post 2 - Review rating = 4.8 Review Count = 1500
Post 3 - Review rating = 4.5 Review Count = 3500
Post 4 - Review rating = 4.5 Review Count = 3000
The below code is sorting the results only by review rating and not by review count. Can somene please let me know what is wrong with the code or if there is something that I am missing?
Also, please find the attached screenshot of results.
$args = array(
'post_type' = 'brewery',
'post_status' = 'publish',
'posts_per_page' = -1,
'meta_query' = array(
'review_rating_meta' = array(
'key' = 'review_rating',
),
'reveiw_count_meta' = array(
'key' = 'reveiw_count',
),
),
'orderby' = array(
'review_rating_meta' = 'DESC',
'reveiw_count_meta' = 'DESC',
)
);
Topic meta-query custom-field custom-post-types Wordpress
Category Web