WordPress.org

Ready to get started?Download WordPress

Forums

OptionTree
[resolved] get_option_tree() & ot_get_option() (11 posts)

  1. simo2k12
    Member
    Posted 1 year ago #

    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/

  2. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    Why doesn't ot_get_option('feat_cat') work for you?

  3. simo2k12
    Member
    Posted 1 year ago #

    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.

  4. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. simo2k12
    Member
    Posted 1 year ago #

    I think you misunderstood me. It actually outputs the text "Array" not an array of values. See screenshot below:

    http://i.imgur.com/V4q3Oi8.png

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

  6. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    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

  7. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    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);
  8. simo2k12
    Member
    Posted 1 year ago #

    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

  9. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  10. simo2k12
    Member
    Posted 1 year ago #

    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

  11. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic