Support » Plugin: OptionTree » get_option_tree() & ot_get_option()

  • Resolved simo2k12

    (@simo2k12)


    Hey,

    Does anyone know how to echo some values from a checkbox/select type option using ot_get_option? I’ve been using this:

    get_option_tree( ‘feat_cat’, ”, false, false, -1 );

    But now since that will be deprecated, I can’t find a way to do it with ot_get_option.

    Any help is appreciated, thanks.

    http://wordpress.org/extend/plugins/option-tree/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Derek Herman

    (@valendesigns)

    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.

    Plugin Author Derek Herman

    (@valendesigns)

    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’);

    Plugin Author Derek Herman

    (@valendesigns)

    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

    Plugin Author Derek Herman

    (@valendesigns)

    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

    Plugin Author Derek Herman

    (@valendesigns)

    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

    Plugin Author Derek Herman

    (@valendesigns)

    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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘get_option_tree() & ot_get_option()’ is closed to new replies.