How to Randomize the Images with the WordPress WP-Cycle Slideshow Plugin

Earlier this week I reviewed the WP-Cycle plugin, which is an easy to use image slideshow plugin.

One feature that it doesn’t have is a random display of the images. The images are displayed in the upload order. This isn’t such a big deal, if you know this in advance, but I didn’t know a client wanted them displayed randomly until after I had uploaded 30+ images and I didn’t want to delete them and start over.

If you want the the images displayed randomly, you will need to edit the plugin file.

Here’s what you do.

Locate the following lines in the plugin file. In the current version, it started at line 811.

echo '<div id="'.$wp_cycle_settings['div'].'">'.$newline;
foreach((array)$wp_cycle_images as $image => $data) {

In between the two lines add

shuffle($wp_cycle_images);

The code block should now look like the following.

echo '<div id="'.$wp_cycle_settings['div'].'">'.$newline;
shuffle($wp_cycle_images);
foreach((array)$wp_cycle_images as $image => $data) {

The images will now be displayed in a random order. Before editing a plugin file, make a backup of it first.

Of course, if you upgrade the plugin, you will lose your customizations.

The WordPress forums are a great source of information for tidbits like this. I found the solution here.

photo credit: Artiii

It's Time!

Start your WordPress website project now!

Contact Me! >>

Recommended:


Keep Reading:
New System Requirements for WordPress 3.2
WordPress 3.2 Full Page Writing Screen
What To Do If Your Website Has Been Hacked?
4 WordPress Plugins to Assist in Blacking Out Your Site to Protest SOPA on January 18th


Comments

  1. Nadine says

    Hi Guys

    i ahve four images under each other ive duplicated the plugin but after the fourth rotate they start ramdomising i need it to stay in order how can i do this

Comments are closed. Please contact me for specific questions or subscribe to my newsletter.