I’m trying to figure out how to get the results from a select box option and apply them to my theme. When I use a text input or color picker it works fine. But when I use a select box, nothing is changing. Here’s the option:
$options['color_scheme'] = array(
'name' => __('Color Scheme', 'text-domain'),
'desc' => __('Select a color scheme.', 'text-domain'),
'id' => 'color_scheme',
'std' => 'blue',
'type' => 'select',
'class' => 'mini',
'options' => array('blue', 'yellow'));
This code below is where I’m trying to output certain option based on the selection:
if ( of_get_option('color_scheme') == "blue") {
$output .= "#header {background:#000066;}n";
}
else if ( of_get_option('color_scheme') == "yellow") {
$output .= "#header {background:#FFFF66;}n";
}
if ($output <> '') {
$output = "<!-- Custom Styling -->n<style type="text/css">n" . $output . "</style>n";
echo $output;
}
I use the same options framework plugin and this is how I specify a select menu using this framework;
Note that the
options
parameter accepts;Where as in your instance you have only specified the label using;
Which means blue has a value of
0
and yellow has a value of1
.Therefore the following is incorrect,
As it should be,
If you want to check by a value name of blue or yellow then your array should look like,