syntax for quer arg in taxonomie field

Support MB Builder syntax for quer arg in taxonomie fieldResolved

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #42591
    Ole PoetterOle Poetter
    Participant

    Hi,

    how is the correct syntax for the query args of the taxonomy field?
    https://imgur.com/OqFikKA

    I try to exclude the term id 9.

    I did it in different ways, but don't get it.

    Kind regards,
    Ole

    #42602
    PeterPeter
    Moderator

    Hello,

    You should remove the single quote in the key box and put 9 in the value box, like this https://imgur.com/SHg0Rxv

    Refer to the documentation https://docs.metabox.io/extensions/meta-box-builder/#custom-settings

    #42604
    Ole PoetterOle Poetter
    Participant

    Thanks! It works.

    #42606
    Ole PoetterOle Poetter
    Participant

    Quick additional question.

    Is there a way a filter or somthing to override this qyery arg?

    I want to exclude the term only on frontent, but not on backend.

    Kind regards,
    Ole

    #42622
    PeterPeter
    Moderator

    Hello,

    You can use the filter hook rwmb_normalize_{$field_id}_field to override the field settings. Please follow the documentation https://docs.metabox.io/filters/rwmb-normalize-field/

    #42627
    Ole PoetterOle Poetter
    Participant

    Hi Peter,

    I'm not sooo goog in developing, so maybe you can assist.

    I tried it this way, but it doesn't works:

    add_filter( 'rwmb_normalize_kind_of_stuff_field', function( $field ) {
        $field['query_args'] => [];
        return $field;
    });
    #42672
    PeterPeter
    Moderator

    Hello,

    You can use the function is_admin() to check if it is the admin area and remove the query args. For example:

    add_filter( 'rwmb_normalize_kind_of_stuff_field', function( $field ) {
        if( is_admin() ) {
            $field['query_args'] => [];
        }
        return $field;
    });
    #42673
    Ole PoetterOle Poetter
    Participant

    Hi Peter,

    The condition is_adminbis clear.
    But the whole function does not work for me.

    Kind regards,
    Ole

    #42679
    Ole PoetterOle Poetter
    Participant

    I'm looking for a way to exclude one term id in this taxonomy field on MB Frontend Submission form, but have alle term id's in wp backend.

    I doubt if this is the right way.

    Peter, can you please assist for a right way?

    Kind regards,
    Ole

    #42700
    PeterPeter
    Moderator

    Hello,

    It is a little bit difficult to remove the query args in the admin area if you use the field type select_advanced. Please use this code to do that:

    add_filter( 'rwmb_normalize_taxonomy_hke7085j6ft_field', function( $field ) {
        if( is_admin() ) {
            unset( $field['query_args']['exclude'] );
            unset( $field['js_options']['ajax_data']['field']['query_args']['exclude'] );
        }
        return $field;
    } );
    #42704
    Ole PoetterOle Poetter
    Participant

    Hello Peter,

    thank you very much!
    It works!

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