Shuffle within structure items

Hello,

I’m trying to randomly shuffle the items from an structure field so every time you refresh it shows one of the many items in that structure.

I’ve tried with the documentation here but I can’t seem to figure it out.

Does someone know if there’s a trivial way to achieve that?
Thanks!

Actually got it solved from last comment in this post.

That post you found is rather outdated. You can use shuffle() instead:

$randomItem = $page->structurefield()->toStructure()->shuffle()->first();

Amazing, thanks!