Randomized Gallery


I am very new (as in literally just found out about) Wix codes, and what I would like to do is have my gallery on the homepage, but instead of the order of the photos being by date added, I’d like them to randomize each time the page is loaded (and later I will look into creating a search function to search images based on their content).

Does anyone know whether this is even possible?

Many thanks in advance!

Have you searched this forum? I remember Tal having answered this question before with examples, ages ago.

Hello earthobserver.

First you need to get gallery items with wixData.query()
Then you can create function that will sort items, in whatever order you want.
Then set $w(“#myGallery”).items = sortedItems;

I’m new to coding as well and would love this on my homepage. I’m using the Pro gallery. Where/how do I locate the wixData.query()?