WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using this code to get my options

echo eh_get_option('eh_slide_image_4');

Using the options framework from http://www.wptheming.com

I have 8 options set up using the above tag like

echo eh_get_option('eh_slide_image_1');
echo eh_get_option('eh_slide_image_2');
echo eh_get_option('eh_slide_image_3');
echo eh_get_option('eh_slide_image_4');
echo eh_get_option('eh_slide_image_5');
echo eh_get_option('eh_slide_image_6');
echo eh_get_option('eh_slide_image_7');
echo eh_get_option('eh_slide_image_8');

I want to display only 4 at a time and have them on random. Anyway to do this?

I should add the entire code looks like this

<div class="box"> 
  <img src="<?php echo eh_get_option('eh_slide_image_1'); ?>" />
      <p><?php echo eh_get_option('eh_slide_text_1'); ?></p>

So it would also need to match the text with the image

share|improve this question

closed as off topic by Rarst Jun 8 '13 at 20:33

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

There's nothing WordPress-specific about this, just some simple php:

// generate an array of numbers
$numbers = range( 1, 8 );

// shuffle the array in random order
shuffle( $numbers );

// use the first 4 values from the randomized array of numbers
echo eh_get_option( 'eh_slide_image_' . $numbers[0] );
echo eh_get_option( 'eh_slide_image_' . $numbers[1] );
echo eh_get_option( 'eh_slide_image_' . $numbers[2] );
echo eh_get_option( 'eh_slide_image_' . $numbers[3] );

If you have a lot of markup to repeat, you can output things in a loop:

$numbers = range( 1, 8 );
shuffle( $numbers );
for ( $i = 0; $i < 4; $i++ ) {
    echo eh_get_option( 'eh_slide_image_' . $numbers[$i] );
share|improve this answer
This does not include anything about eh_slide_text – Noob Theory Jun 8 '13 at 22:01
just copy/paste the line that outputs the image and change 'eh_slide_image_' to 'eh_slide_text_' – Milo Jun 8 '13 at 22:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.