I noticed that D’Arcy Norman posted a little thing about how he setup some rotating banners based on my site … thanks! It isn’t like I invented the stuff but hey, I appreciate the nod! Since then, I’ve had a couple of people ask how its done. Here’s the simple way … first, install the Random Files plugin and put a bunch of headers into a directory and point to it. Then drop this code into your index.php file (if you are using the kubrick style) for WordPress by finding the #header style directive and changing it to:
#header {
background: url(“< ?php echo random_file('/images/random', 'jpg gif png jpeg'); ?>“) no-repeat bottom center;>
That assumes you have a directory called “random” in your images directory … that’s really it … oh, you might want to take a bunch of good pictures to make it worth while … not sure I’ve done that, but I’m doing what I’m doing. Thanks to Elliot Black for helping me get it rolling!
After its all said and done, watch your traffic explode as you sit there and reload your own blog 20 times to see it work!
Um… There’s a plugin for that? Oops! 🙂 I just rolled my own widget for it. Looks like it does basically the same thing. I also wrote the simple page to display them all at once to satisfy the curious. It’s just a simple “list all files in a given directory matching a particular pattern in the filename” thing. I can share the code for that if it helps.
Yeah, I love to have that little piece of code … it would be nice to give people a chance to see all of the headers like you did. I was wondering how you did that with Random Files. Sorry you had to put it together yourself, but it looks and works great! Love the pictures you have rolling through there!
No worries, Cole. Actually I kind of enjoyed rolling my own solution 🙂 I’ll package up what I did and post it when I get a chance. It’s really quite simple code (even for a non-PHP guy like myself – but PHP is so easy that anyone who can understand code can do PHP…)
Any idea how one could use random files for changing header graphics, when the background image is defined in the CSS, and not the page code?
I’m not sure how to pull it out, without screwing up the css controlled layout.
I’m using the Golden Gray theme.
Looks great on your site.
Couldn’t get that method to work for some reason, though I’ve got it working with a different solution.
If anyone esle is interested i’ve written it up
And it doesn’t require any mod to the K2 base files.