I have created an options page in my WordPress theme that allows the user to input a url/upload an image to an input field. The field has the name headerimage_options[image] and when it is populated it can be saved and outputted in the theme with the following code: <?php echo esc_url( $headerimage_options['image'] ); ?>
I have created three inputs with the names [image], [image2] and [image3]. I can save the content of the input fields and output all of the images using the code below:
<?php $headerimage_options = get_option( 'headerimage_options' ); ?>
<img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image'] ); ?>"/>
<img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image2'] ); ?>"/>
<img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image3'] ); ?>"/>
My question is how do I output just one of the images at random? I've searched but couldn't find an answer anywhere.