Meta Box
Support Forum
Support › Meta Box Builder › syntax for quer arg in taxonomie fieldResolved
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
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
Thanks! It works.
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.
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/
rwmb_normalize_{$field_id}_field
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; });
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; });
The condition is_adminbis clear. But the whole function does not work for me.
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?
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:
select_advanced
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; } );
Hello Peter,
thank you very much! It works!