Archived topic
How to have custom image header element that switches image on page refresh?
7 replies · Started by David Bennett on March 28, 2020
The set up I have is a header element with a custom image set as a background image.
I would like to try so that when the page is refreshed, a different custom image is presented to the visitor. Or that visitor 'A' might see one custom image and another visitor see a different custom image.
The site is cached with Litespeed and goes through Cloudflare.
Hi there,
This should help:
https://generatepress.com/forums/topic/pulling-random-images-for-header-element/#post-965489
Thanks. I tried it on a staging site. It rotated from the 'default' image to the 'substitute' image, but then it stayed on the substitute image. I cleared the cache etc.
How many images did you add?
Can you link me to the staging site?
Hi Leo,
I set two images. When it didn't work yesterday I put the code on hold. Just now I set three images and reactivated the snippet.
How should I link you to the site? Should I just put the URL here? Maybe I put it in the original question - the site begins 'stage.fl.....
You can edit the original topic and and edit the Private URL field.
Done - thank you.
Hi there,
I'm seeing multiples backgrounds if I continue to refresh the page. Since the code grabs the URLs at random, it's possible that the same image shows up consecutively.