syntax for quer arg in taxonomie field
Support › MB Builder › syntax for quer arg in taxonomie fieldResolved
- This topic has 10 replies, 2 voices, and was last updated 2 years, 3 months ago by
Ole Poetter.
-
AuthorPosts
-
July 16, 2023 at 2:05 AM #42591
Ole Poetter
ParticipantHi,
how is the correct syntax for the query args of the taxonomy field?
https://imgur.com/OqFikKAI try to exclude the term id 9.
I did it in different ways, but don't get it.
Kind regards,
OleJuly 17, 2023 at 7:40 PM #42602Peter
ModeratorHello,
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
July 17, 2023 at 7:47 PM #42604Ole Poetter
ParticipantThanks! It works.
July 17, 2023 at 8:22 PM #42606Ole Poetter
ParticipantQuick 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,
OleJuly 18, 2023 at 4:32 PM #42622Peter
ModeratorHello,
You can use the filter hook
rwmb_normalize_{$field_id}_fieldto override the field settings. Please follow the documentation https://docs.metabox.io/filters/rwmb-normalize-field/July 18, 2023 at 5:39 PM #42627Ole Poetter
ParticipantHi 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; });July 19, 2023 at 10:45 PM #42672Peter
ModeratorHello,
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; });July 19, 2023 at 10:48 PM #42673Ole Poetter
ParticipantHi Peter,
The condition is_adminbis clear.
But the whole function does not work for me.Kind regards,
OleJuly 20, 2023 at 12:27 PM #42679Ole Poetter
ParticipantI'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,
OleJuly 20, 2023 at 10:41 PM #42700Peter
ModeratorHello,
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; } );July 21, 2023 at 1:13 AM #42704Ole Poetter
ParticipantHello Peter,
thank you very much!
It works! -
AuthorPosts
- You must be logged in to reply to this topic.