php - Ordering by multiple meta keys wordpress -


im aware there several posts relating issue yet find fix current problem.

im reasonably new wordpress , still getting used it, however...

the problem

i'm implementing front end sorting system users filter out schools, using rating plugin (comment rating field pro) , issue have when users sort star rating want sub sort number of reviews (comments). sorting rating , ignoring number of comments , sorting title. have tried various combinations of query parameter arrays such meta_query , multiple meta keys issue appears refuses sort second value. both numbers in database.

tl:dr needs sort stars , number of reviews.

unfortunatly custom query out of question array being fed plugin appears accept array of args.

this sort of idea im going (this not work)

array ( [post_type] => surf-school [posts_per_page] => 12 [paged] => 0 [meta_key] =>      crfp-average-rating [orderby] => meta_value crfp-total-rating [order] => desc ) 

any appreciated driving me insane!

thanks in advance.

update

i have managed fix using comment reply post appears have been deleted :(

i managed adding filter wp_query , forcing custom order seen here plugin api/filter reference/posts orderby - codex

function edit_posts_orderby($orderby_statement) { $orderby_statement = "wp_postmeta.meta_value desc, wp_posts.comment_count desc"; return $orderby_statement; 

}

placed in functions.php ,

add_filter('posts_orderby', 'edit_posts_orderby'); 

placed before query. hope helps else :)


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -