Random Headers: Followup

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!

5 thoughts on “Random Headers: Followup

  1. 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.

  2. 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!

  3. 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…)

  4. 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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.