I have a Wordpress function that loops thru 10 input fields & saves the data from those input fields. The data entered is either an absolute or relative link to an image. The loop looks like this.
<?php for ($i = 1; $i < 11; $i++) { ?>
<input type="text" name="<?php echo 'fresh_banner'.$i ?>" value="<?php echo $settings['fresh_banner'.$i]; ?>" />
<?php } ?>
The saving looks like this:
<?php
function freshSaveThemeSettings() {
$settings = get_option( "freshThemeSettings" );
for ($i = 1; $i < 11; $i++) {
$settings['fresh_banner'.$i] = $_POST['fresh_banner'.$i];
}
$updated = update_option( "freshThemeSettings", $settings );
}
?>
To output one of the images, it goes something like this:
<?php
$settings = get_option( "freshThemeSettings" );
echo $settings['fresh_banner1'];
?>
What I'm trying to do is randomly display one of the images at a time. Each time the page is refreshed, a new image would be displayed. What is the best way to go about this?