Hi, i have two taxonomy dropdown using the same taxonomy, for the first i’m doing something like this :
function firstdropdownfilter( $args, $field, $post_id ) {
$args['parent'] = 0;
return $args;
}
add_filter( 'acf/fields/taxonomy/query/name=firstdropdwon',
'firstdropdownfilter', 20, 3 );
The second dropdown, it must be “influenced” form what i’ve selected in the first .. and i’m doing like this :
JS
acf.add_filter(
'select2_args',
function( args ) {
if ( typeof args.ajax.data == 'function' ) {
var old_data_func = args.ajax.data; // We'll keep this for maximum compatibility, and extend it.
args.ajax.data = function(term, page) {
var default_response = old_data_func( term, page ); // Call the old, default function.
default_response.firstdrpdwn = function() {
return jQuery('#acf-field_55890984e822f').val();
};
return default_response;
}
}
return args;
}
);
PHP :
function seconddropdownfilter( $args, $field, $post_id ) {
$make = isset($_REQUEST['firstdrpwn']) ? (int) $_REQUEST['firstdrpwn'] :
false;
if ( !$make ) $args['parent'] = -1;
else $args['parent'] = (int) $make;
return $args;
}
add_filter( 'acf/fields/taxonomy/query/name=seconddropdown',
'seconddropdownfilter', 20, 3 );
The first it’s OK, the second does not working .. I don’t know if i’m using select2 .. Please help me
Thanks