With multiple checkbox options, how do I check to see which options were selected?
I’m missing something and I can’t figure it out.
Thanks 
one thing you can do is open up the database and look in the tables for the values. When you are using check boxes with option tree, you test the key that you set. so for example. I set up two checkboxes to show and hide a box on the homepage. my key that I set up was called social_share and the value of the checkbox is Show and Hide so I can test for it like this
$options = get_option('option_tree');
if( $options['social_share'] == 'Show') :
Do something here;
endif;
This is useful for something I was trying to work out yesterday. Cheers CyberShot!
CyberShot said
one thing you can do is open up the database and look in the tables for the values. When you are using check boxes with option tree, you test the key that you set. so for example. I set up two checkboxes to show and hide a box on the homepage. my key that I set up was called social_share and the value of the checkbox is Show and Hide so I can test for it like this$options = get_option('option_tree'); if( $options['social_share'] == 'Show') : Do something here; endif;
Thanks,
That does work for a single selected box but not when multiple boxes are selected.
What I am attempting to do,
I have checkboxes for meta information (Author, Date, Category and Tags) and information is shown based on what checkboxes are selected.
Showing results from multiple boxes selected is where I am running into problems.
well, you could use more than one if statement to test for all the values and then echo them if they are present
I am wondering if you could use a switch statement for this?
<?php $options = get_option('option_tree');
$my_option = $options['author_options'];
switch ($my_option) {
case "author":
echo "author info";
break;
case "date":
echo "date info";
break;
case "category":
echo "category info";
break;
}
?>
I don’t know much about the switch statement. You could try something like this
