Hey,
I have connected two taxonomies.
Example:
City A
City B
= District 1
City C
City D
= District 2
Now I have a CPT in which 2 fields are "City" and "District".
If you select City A, District 1 should be automatically selected or displayed as the only option.
I thought I could do this with simple query_args, but it doesn't seem to work. Where is the error?
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = 'schulamt_';
$meta_boxes[] = [
'title' => __( 'Daten', 'your-text-domain' ),
'id' => 'schwimmhalle',
'post_types' => ['schwimmhalle'],
'fields' => [
[
'name' => __( 'Stadt', 'your-text-domain' ),
'id' => $prefix . 'stadt',
'type' => 'taxonomy',
'taxonomy' => ['stadt'],
'field_type' => 'select',
'placeholder' => __( 'Stadt auswählen', 'your-text-domain' ),
],
[
'name' => __( 'Schulamt', 'your-text-domain' ),
'id' => $prefix . 'schulamt',
'type' => 'taxonomy',
'field_type' => 'select',
'placeholder' => __( 'Schulamt auswählen', 'your-text-domain' ),
'query_args' => [
'relationship' => [
'id' => 'schulamt-stadt',
'from' => get_the_ID(),
],
],
],
],
];
return $meta_boxes;
}