Display query post based on two orderby value in wordpress
I have been trying to display popular posts (based on view counts) and fetching them randomly using array in orderby
but it doesn't seem to be working. The reason I want them to display randomly is because I don't want the same post to be displayed repeatedly to both new repeated visitors as the views count increases naturally.
Here is the code I tried:
$popularpost = new WP_Query(
array(
'category' = 'comedy',
'posts_per_page' = 4,
'meta_key' = 'post_views_count',
'orderby' = array ('meta_value_num', 'rand'), //this is the one I want both rand meta_value_num to retrieve
'order' = 'DESC'
)
);
while ( $popularpost-have_posts() ) : $popularpost-the_post();
the_permalink();
the_title();
if ( has_post_thumbnail() ):
the_permalink(' ');the_title();
the_post_thumbnail();
endif;
the_excerpt(); // echo the excerpt
endwhile;
Everything is working except that it doesn't fetch randomly. The same post are always shown.
Topic menu-order meta-query popular-posts Wordpress
Category Web