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)) %}

2 Answers 2

48

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

{% for entry in craft.entries.section('team').type('mainPeople').order('RAND()') %}
1
  • Doh! I'd tried that, but forgot the quote marks. Thanks.
    – Willans
    Commented Sep 23, 2014 at 12:35
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()') %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.