Why doesn’t ot_get_option('feat_cat') work for you?
It doesn’t. This is a multicheck category option, using the ot_get_option echos “Array” while get_option_tree echos all categories. Should I add something else to the new code? I couldn’t find anything on the documentary page.
get_option_tree( 'feat_cat', '', false, false, -1 ); also echos an array.
I just tested it with a category checkbox and a regular checkbox and when more than one is selected they both return an array.
I think you misunderstood me. It actually outputs the text “Array” not an array of values. See screenshot below:
View post on imgur.com
First line is being output by this:
get_option_tree( ‘feat_cat’, ”, false, false, -1 );
While the second line that says “Array” is output by:
ot_get_option(‘feat_cat’);
That’s not what I get when I use the same functions. Both echo an array of values when you print_r() the output. Can you send me a copy of your settings export and a sample of the code you use in your theme to derek[at]valendesigns.com it’s been a while since I used that function.
Cheers,
Derek
A quick fix though, if you need a list of comma separated id’s would be to do:
$feat_cat = ot_get_option('feat_cat');
echo implode(',', $feat_cat);
Sweet, that did the trick, thank you.
Does that mean using the regular ot_get_option(‘feat_cat’) alone doesn’t echo the values separated with commas? If it does and it just doesn’t work with me, I’ll email you the settings export file for the sake of debugging it.
Thanks again,
Simo
No, sorry it does not echo the csv version. That was deprecated in the 1.x branch. Unfortunately, I for some reason can’t get the deprecated function to echo a csv so theres that, but in general you should modify your code to use the new features, as those are the ones I support.
Sorry for the confusion. Cheers!
Alright then, thanks for clarifying. I was under the impression that it does, which is why I was curious to why it wasn’t working for me.
Regards,
Simo
The new version works like so: If it’s a single value it will return that value. If it’s an array of values it will return the array. It just returns what is saved in the DB, no filtering.