This simple script functions as a replacement script for Matt Mullenweg’s classic rotation script from 2003. This script fetches a random image from the native WordPress Media gallery of file attachments. It was created to give my clients full control over their galleries of random backgrounds, headers, etc. I build sites and coach clients to be 100% independent within the native WordPress environment.
Just like the original file, it’s not a plugin, therefore the footpath and render time is minimal. It calls upon your wp-config.php file so you should not have to configure anything other than your file name wildcard.
All your images should be the right size but it is possible to use it with Timthumb. I works with WordPress 2.6+ and is based on standard installs. You may modify and distribute as you wish or embed in your themes.
Current version: 1.0
After saving this file as rotator.php, edit it in a text editor.
- Edit the $wildcard with the name of your images.
- Upload all your images in WordPress’ Media interface.
- Place this file in a folder named scripts in /wp-content
- Test your results by calling this file directly @ http://yourdomain.com/wp-content/scripts/rotator.php
- Change the value of $test to 0 so the script redirects to your image.
- In your theme, change the name of the image you wish to rotate to:
If you would like to control many random image groups, un-comment the switch block and call your ?place= in addition to the script.