Attention: It's order, not orderby.
According to wordpress docs, there are only two options to order, which are ASC or DESC.
The problem is:
I would like to randomize the posts I've selected, not randomize WHICH posts I select.
Here's my code for better explanation:
<?php
return array(
"post_type" => "listings",
"post_status" => "publish",
'meta_query'=>array(
array('key'=>'featured_until','value'=>$current_date, 'compare'=>'>'),
),
'meta_key'=>'featured_until',
"orderby" => array(
'featured_until' => 'RAND', /* How can I make this work? */
'date' => 'DESC'
),
"suppress_filters" => true,
"facetwp" => true,
"posts_per_page" => 16
);
It's a listings website. The code above selects 16 posts to show on the first page.
First, it tries to find 16 featured listings. If there aren't that many featured listings, it completes with regular listings ordered by date.
The question is: How can I order the featured listings by RANDOM, instead of ASC or DESC?
$args = array( 'orderby' => 'rand', 'posts_per_page' => '1', ); $query = new WP_Query( $args );