19

I was wondering if it's was possible to order section entries by random.

Example:

{% for entry in craft.entries.section('team').type('mainPeople').order('title random)) %}
nicael
  • 2,382
  • 7
  • 27
  • 48
Willans
  • 193
  • 1
  • 4

2 Answers2

48

You can use MySQL's RAND() function inside your order method:

{% for entry in craft.entries.section('team').type('mainPeople').order('RAND()') %}
Mike Pepper
  • 4,391
  • 17
  • 26
1

.order() is deprecated in Craft 3 and doesn't work in Craft 4, use orderBy() instead.

{% for entry in craft.entries.section('team').type('mainPeople').orderBy('RAND()') %}
Brad Bell
  • 67,440
  • 6
  • 73
  • 143
Samuel
  • 69
  • 6