How get random posts and order by date?

Question

I need get some random posts and order there by date.

To get random posts i use:

$query = new WP_Query(
    [
      'post__in' => $post_id_array,
      'posts_per_page' => $number,
      'orderby' => 'rand'
    ]
  );

After to order by date i try add this:

'orderby' => ['rand' => 'ASC', 'date' => 'DESC']

But it is not work correctly. How i can do this?

0
kostikovmu 1 year 2019-12-11T14:13:41-05:00 0 Answers 96 views 0

Leave an answer

Browse
Browse