Slider Element Slide Order

Is it possible to randomize or shuffle the order of slides in the slider element so that the order is different each time the page is visited?

Hey @Marquis :wave:

You can do it with a small line of JS, if your slider is linked to data.
In my example. I bound my slider to a variable I named Randomized slides, empty array.

I created a workflow Randomize slides, which change value of Randomized slides with my collection in a random order.

return yourCollection_Or_InitialData.sort((a, b) => 0.5 - Math.random());

And with a On page load trigger, I execute the Randomize Slide workflow

2022-12-14 11.34.15 AM

1 Like

Thanks, @Kevin! This was incredibly helpful. I added the code and it is working. When I refresh the page, the order of the slides appears to change each time already. My slider is bound to a data set. Where would I bind the variable and what would the workflow do?