WP_Query: ordering by meta_value_num & comment_count

I would like to create create a query that sorts posts by both number of comments and meta_value_num. I can get it to work for one or the other, but not both together.

I have tried this:

Read More
'posts_per_page' => '3',
'meta_key' => 'crfp-average-rating',
'orderby' =>'comment_count meta_value_num',
'order' => 'DESC'

But it only orders by meta_value_num

Related posts

1 comment

  1. As mentioned in my comment, you should switch the order of your orderby parameters. WordPress will treat the second parameter as the fallback:

    'orderby' =>'meta_value_num comment_count',
    

Comments are closed.