Website owners often want to add interest to their website by showing a different header image each time a page is loaded. The WordPress codex includes instructions for implementing header image rotation on your WordPress powered site, recommending a script by Matt Mullenweg.
The script works very well. It’s easy to implement, and to add or remove images to or from the rotation, you just need to upload them to or delete them from a specific folder on your server. Once you’ve uploaded the script and some images for it to use, you call the image using the following code in your theme files:
<img src="<?php bloginfo('template_directory'); ?>/imagedirectory/rotate.php" alt="" />
The only problem is that in FireFox it doesn’t work. FireFox caches content aggressively, and it will run the rotation script, cache the result, and keep showing the same header image over and over again.
To prevent this from happening, we need to convince FireFox that the rotation script isn’t the kind of thing it should cache. To do this, we can pass a randomly generated variable to the script to make it look dynamic:
<img src="<?php bloginfo('template_directory'); ?>/imagedirectory/rotate.php?fakequerystring=<?php echo rand(0,1000); ?>" alt="" />
The rotation script won’t do anything with the variable, but FireFox isn’t to know that, so every time you pass a different variable to the script FireFox will run it again rather than loading a cached image.