Answer the question
In order to leave comments, you need to log in
Multi-factor sorting posts in a wp_query loop?
Good afternoon.
Got a question. There is such a construction for displaying posts in a custom taxonomy:
$args = array(
'post_type' => 'my-custom-type',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'ratings_users',
'type' => 'NUMERIC',
),
array(
'key' => 'ratings_average',
'type' => 'NUMERIC',
),
array(
'key' => 'views',
'type' => 'NUMERIC',
),
),
'orderby' => 'meta_value_num',
'order' => 'DESC',
);
$query = new WP_Query(
array_merge(
$args,
$wp_query->query
)
)
Answer the question
In order to leave comments, you need to log in
You need GROUP BY. Read the doc on the posts_groupby hook
https://codex.wordpress.org/Plugin_API/Filter_Refe...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question