Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    You’re going to need to determine a way to grab all the current tags in your page, and create an array of them for the options parameter of that extention’s implementation. We don’t have any way to determine or know what tags are associated with the page, so we don’t really have any way to offer suggestions on how to achieve that.

    Thread Starter nagarjunsarathy

    (@nagarjunsarathy)

    Hi,

    Thank you Michael for the response.
    I am ok with tags not getting determined associating with page.
    I am using DWQA plugin that provides me with “dwqa-question_tag” taxonomy that holds all tags, so can I create select2/selectize fields using that taxonomy?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I don’t see why not. It sounds like you have a taxonomy which has terms created, and you need to feed those terms into the select2 field input.

    I would recommend reading up on https://developer.wordpress.org/reference/functions/get_terms/ to get started. You can some or all terms associated with a given taxonomy, and it’ll return an array of WP_Term objects.

    You could then loop through those results and construct an array to pass to select 2.

    Example possible:

    $select2_terms = array(
        'term_slug' => 'Pretty term name',
        'other_term_slug' => 'Another pretty term name'
    );
    

    All of which would come from the WP_Term objects. You would need to read up on the Select2 documentation to make sure you’re returning data in a way they expect, to help make sure it works.

    All in all, it should be wholly possible, just a matter of getting your data ready.

    Thread Starter nagarjunsarathy

    (@nagarjunsarathy)

    Hi Micheal,

    Thank you for the response. Your answer helped me a lot in achieving this.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome. Let us know if you need help with anything else.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to implement cmb-field-select2’ is closed to new replies.