Answer the question
In order to leave comments, you need to log in
How to display entries from the beginning to the new ones and add random ones with a low rating?
Hello.
In the records there is such a parameter "Rating".
Entries with a rating between 10 and 100 should be displayed in order, from highest to lowest.
And those that are less than or equal to 10 should randomly appear among those that are displayed in order.
How to implement this?
I display records, records with a rating of more than 10, I was able to display. And how to throw random ones with a low rating to them. Don't know(
$query = new WP_Query( array(
'post_type' => 'models',
'posts_per_page' => -1,
'meta_query' => array(
'reiting_query' => array(
'key' => 'reiting',
'value' => 10,
'type' => 'NUMERIC',
'compare' => '>',
),
),
'orderby' => 'reiting_query',
) );
Answer the question
In order to leave comments, you need to log in
Based on complexity
should randomly appear among those that are displayed in order
$args1 = array(
// тут параметры первого массива
'post__in' => $ids,
);
$args2 = array(
// тут параметры второго массива с низким рейтингом
'orderby' => 'rand',
'post__in' => $ids,
);
$args1 = get_posts( $args1 );
$args2 = get_posts( $args2 );
$merged_ids = array_merge( $args1, $args2 );
$args_final = array(
// тут параметры общего массива
'post__in' => $merged_ids,
'orderby' => 'post__in',
);
$query = new WP_Query( args_final );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question