Outputting results from select box option in options panel

I use the same options framework plugin and this is how I specify a select menu using this framework;

$test_array = array(
    'one' => __('One', 'options_framework_theme'),
    'two' => __('Two', 'options_framework_theme'),
    'three' => __('Three', 'options_framework_theme'),
    'four' => __('Four', 'options_framework_theme'),
    'five' => __('Five', 'options_framework_theme')
);

$options[] = array(
    'name' => __('Select a Tag', 'options_check'),
    'desc' => __('Passed an array of tags with term_id and term_name', 'options_check'),
    'id' => 'example_select_tags',
    'type' => 'select',
    'options' => $test_array);

Note that the options parameter accepts;

'options' => array('value' => 'label')

Where as in your instance you have only specified the label using;

'options' => array('blue', 'yellow')

Which means blue has a value of 0 and yellow has a value of 1.

Therefore the following is incorrect,

if ( of_get_option('color_scheme') == "blue") 

As it should be,

if ( of_get_option('color_scheme') == 0) //0 for blue 1 for yellow

If you want to check by a value name of blue or yellow then your array should look like,

'options' => array(
    'blue' => 'Blue',
    'yellow' => 'Yellow'
 )

Leave a Comment