Filter a selected child group of taxonomy terms

Support MB Frontend Submission Filter a selected child group of taxonomy terms

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #37169
    Cynthia ConserCynthia Conser
    Participant

    Situation:
    On a frontend form, I have created a Taxonomy Advanced field for a hierarchical taxonomy named Repositories. Currently, I am using the Select Tree type and the form displays all four parent terms in the top box and the associated child terms in the bottom box when one of the parent terms is selected.

    What I want instead:
    For this frontend form, I would like to use a Select Advanced type that displays the child terms for just one of the parent terms (Websites). Please advise.

    #37177
    Long NguyenLong Nguyen
    Moderator

    Hi Cynthia,

    You can use the setting query_args and pass the term ID to the argument parent to get child terms. For example:

    [
        'id'         => 'project_cat',
        'title'      => 'Project Categories',
        'type'       => 'taxonomy_advanced',
        'taxonomy'   => 'project_cat',
        'ajax'       => true,
        'query_args' => [
            'parent' => 10, //change 10 to the term website ID
        ],
    ],

    Read more on the documentation https://docs.metabox.io/fields/taxonomy-advanced/
    https://developer.wordpress.org/reference/classes/wp_term_query/__construct/

    If you are using the builder, please follow this documentation https://docs.metabox.io/extensions/meta-box-builder/#dot-notation

    #37186
    Cynthia ConserCynthia Conser
    Participant

    Thank you for your prompt reply. I am using the builder and have tried entering the following under Query args to no avail:

    website_query.0.taxonomy repository
    website_query.0.field slug
    website_query.0.terms website

    Obviously, I am clueless. What should I be doing instead?

    #37203
    Long NguyenLong Nguyen
    Moderator

    Hi,

    For the field taxonomy_advanced, you can use the option Query args when creating the field. Please check this screenshot https://monosnap.com/file/NNHNgCptbMDgJ59nWkpW6Ubr70SvL8

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.