Problem:
I want to create a random background image for a div that changes every time the page loads. I am using classic Toolset views and a Genesis child theme.
Solution:
- Create an image custom field and make it a repeating field with the slug set to "slider-images."
- Create a shortcode as described in the documentation link below.
- To use the random image as a background, add custom HTML code inside the content template or wherever you want to use the shortcode, with the following format:
<div class="background-container" style="background-image: URL([types field='slider-images' index="[generate-rand-num field='slider-images' output='raw']"][/types])"> Content of the DIV </div>
Relevant Documentation:
https://toolset.com/forums/topic/choose-random-image-from-custom-field/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Our next available supporter will start replying to tickets in about 0.08 hours from now. Thank you for your understanding.
This topic contains 2 replies, has 2 voices.
Last updated by 1 year, 9 months ago.
Assisted by: Christopher Amirian.