M
M
Mikhail Kostikov2019-12-11 19:41:16
JavaScript
Mikhail Kostikov, 2019-12-11 19:41:16

How to sort random posts by date in WordPress?

It is necessary to display several random entries sorted by date.

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

Tried it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-01-18
@webe

scrollIntoView
demo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question