Random background image
-
This thread has a great tip for using random background images. The topic is marked “resolved” but I have a question about it. I don’t know how to make it “unresolved” since I am not the original poster.
I don’t know the etiquette for this so I’m just going to post two quick excerpts from the thread:
Original question: I would like to place a random background image function on my main wordpress page so that each time the user visits the blog or refreshes the page, a random background image appears on the entire page.
Answer
simple HTML, but adjust to what you need inside your header.php file<background="rotate.php">
Matt of wordpress fame! has an example here:
https://photomatt.net/scripts/randomimage/This is great code. Simple & elegant.
I do have one question on implementation.
I am rotating the background image for the pages.
However, I want to use a different random background image on the index.php and single.php templates. I am using the same code to get the image in each file
<style type="text/css">body { background-image: url(../../../images/backgrounds/rotate.php); } </style>
However, when I go from page to page my FireFox cache is loading the same background image instead of getting a new one (Internet Explorer 7 seems to load it new each time). If I <shift>+”Refresh” I get a different background each time but unless I do the force refresh each page loads with the cached background.
Is there a good way to work around this?
I assume I can use a different “random image” directory for each template and since I would call the random image from a different place there would not be the same one in the cache, but that seems very clunky.
Any ideas?
- The topic ‘Random background image’ is closed to new replies.