I have multiple items in my content file. The first item is placed in a foreach loop, the remaining items are placed in a separate foreach loop, like this:
// First item <?php $items = $page -> items() -> toStructure() -> offset(0) -> limit(1); foreach($items as $item) : ?> // ... <?php endforeach ?>
// Remaing items <?php $items = $page -> items() -> toStructure() -> offset(1); foreach($items as $item) : ?> // ... <?php endforeach ?>
This works properly in that the first item always gets placed in the first loop, but what I’d actually like is to choose a random item and place that in the first loop.
So when the page loads, item number 4 gets randomly picked, separated from the rest and placed only in the separate, first loop. When the page loads again, a different item number gets randomly picked, and so on.