NO BUG: How to order by random in "Query editor (PHP)"

I have added this into it:

return [
‘post_type’ => ‘ad’,
‘posts_per_page’ => ‘3’,
‘orderby’ => ‘rand’,
];

But the orderby dont work.

Hi Patrick,
Thanks so much for your report!

Unfortunately, I cannot reproduce the issue. Remove the quotes from the posts_per_page value since it’s a number, not a string that needs quotes. This will probably fix your problem.

Best regards,
timmse

didnt fix it, can it maybe be because i develop my website on localwp then it dont work correctly

Hey guys,

I think this is indeed some kind of “bug”. You have to manually set the random seed TTL to 0 if you want a random order on every page load:

return [
  'post_type' => 'event',
  'posts_per_page' => 3,
  'orderby' => 'rand',
  'randomSeedTtl' => 0,
];

Otherwise Bricks uses a default TTL of 60.

I think this should either be documented or Bricks should exclude manual queries from the seed logic.

Best,

André

Thank you that fixed it