Displaying images in random order


I’m trying to achieve a hero image on the homepage that changes every time you refresh the page (i.e not a slideshow).

To do this, I’ve created separate posts each with a different featured image, then used a Looper to display all the posts on the homepage in a random order,

Then on the looper consumer, I’ve set it to only display one post.

However, the same post appears each time, rather than it being a random one.

Could you advise me how I can get it to show one different image each time?



Hello @timgroves,

Thanks for writing to us.

I checked your site it seems that your post setting was correct but ORDER BY RAND() support was not enabled from the WP Engine, I went ahead and clear all the cache and then enable the ORDER BY RAND() query support. Please have a look at your site it is working fine at the moment.

Hope it helps

Gosh you’re good Prakash thank you - I would never have thought it would have been something I needed to change in the hosting settings.

Thanks so much for helping me get to the bottom of it.


Hello Tim,

Glad that we were able to help you. Please feel free to open a new thread if you have any more concerns.


Hi Prakash,

Thanks again for helping me get to the bottom of why the random order wasn’t working.

Having done further testing, I’ve realised it still doesn’t display a random image each time on mobile (but it does on desktop).

I’m assuming this is because of caching on mobile, but I wondered if you’ve any thoughts on how to make it work on mobile too?



Hi Tim,

If the random order is working on the desktop but on the mobile, that might be due to the cache. I would suggest you check once by clearing all types of cache in the mobile and check in the incognito/private mode of the browser.

Hope it helps.

Great thanks Tristup, I’ll look there

Hi Tim,

You are most welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.