-
Hi,
I asked a similar question some time ago. The main focus then was to randomly show page hero elements on specific pages. This time I need just the background image to change. In a perfect world I would not have to create new elements for each and every page. This would make things pretty messy. We have a header element for most of the 15 or so pages. Typically, there is some text overlay like on this page. I would like the images to change randomly after reloading the page. I could write a function that injects some CSS right before the closing HEAD tag. That wouldn’t be super pretty and still messy, but it would do the trick. Do you have a better idea? How would you do this? I don’t use the block editor. Please let me know, if the block editor would provide more functions regarding this specific topic. I try to avoid the block editor, but I don’t want to be stubborn. 🙂
Thank you!
-
Alvind
Hi there,
This definitely requires a custom snippet, as the block editor does not support this feature by default.
Perhaps the method outlined in the following topic post suits your requirements?
https://generatepress.com/forums/topic/random-background-image-in-element-block-page-hero/#post-2275893 -
That would work. Would you approve this approach? There is probably no more elegant solution for this, I guess.
-
Alvind
Personally I would use this approach if I needed to meet such a requirement. 🙂
-
Thanks, Alvind. If it’s good enough for you, it’s good enough for me. 🙂
By the way, I don’t get any notifications of new posts. The Notify-me-checkbox is enabled, of course. I checked the Spam folder. Nothing there. I had the same problem some years ago and changed my email. That worked until recently.
-
Alvind
You’re welcome!
That’s odd. When the notify checkbox is enabled, you should receive an email. Let me know if you get a notification from this reply.
-
Strange. NOW, I got a notification from your reply.
- You must be logged in to reply to this topic.