I was looking for a way to alter the image randomly on my WordPress weblog, but as the header image is called from a CSS file, I was unsure quite how to do it.
I am unsure no more !
PhotoMatt wrote a random image script, the details of which can be viewed here.
Although I use WP, this will work for any blog that has an image called from the CSS.
I did this;
– Created a folder on the server called ‘headers’
– Into that, I uploaded several different images that would suit as a header image.
– I saved the script above as a php file (call it what you will – mine is ‘rotate.php’) and uploaded into the same ‘headers’ folder.
Now I edited the CSS file.
In WP, there is a line in #header which can be used to specify a url for the image to be loaded. This needs a light alteration:
and it is now
Now, when the CSS is called, the background image is chosen randomly by the script.