Pre-programmed Randomness

That’s a pretty consistent theme in all of my interactive work… randomness. It’s a perfect way to introduce variety and gives a project a little bit of the feel of playing a (very simple) game. Your reward for returning is a little bit of new information, and if the experience is enjoyable enough why not keep hitting that refresh button?

Truth is, it’s also nice cover for a site like this where updates and new info may be sporadic. Keeps it fresh without having to update every single day (a big reason I retired the first site, creative burnout). Google loves it too, trust me.

Anyways, today I finally added a little bit of randomness around here, setting up the next development step for the site. For now the sample set is pretty small so it might not appear very random at all, but it’s just proof that it could work on something larger.

Two things:

  1. Never used PHP inside JavaScript code before, but I’m using it here to pull up a random profile pic. A feature that I’d love to see on Facebook.
  2. Getting a random post displayed out of WordPress is extremely easy. Why would I use an extra plugin? Here’s what my code looks like:
    <?php $rand_posts = get_posts('numberposts=1&category=5&orderby=rand'); ?>
    <?php foreach( $rand_posts as $post ) : setup_postdata($post); ?>
    The code block for one of those front page features would go here, blah blah blah.
    <?php endforeach; ?>
    

Both of these are just stop gaps on the way to moving the Google map code over to XML, which will allow so much more flexibility.