Overview
This filter allows you to modify the $args
array which is used to query the terms shown in the taxonomy field. The available arguments can be found in the get_terms() documentation.
Changelog
- Added in v5.0.0
Parameters
Name | Type | Description |
---|---|---|
$args | array | An array of arguments passed to the get_terms() function |
$field | array | An array containing all the field settings |
$post_id | mixed | The ID for the current post being edited |
Usage
There are 3 ways to hook into acf/fields/taxonomy/query
filter.
acf/fields/taxonomy/query
– filter for every fieldacf/fields/taxonomy/query/name={$field_name}
– filter for a specific field based on it’s nameacf/fields/taxonomy/query/key={$field_key}
– filter for a specific field based on it’s key
functions.php
<?php
function my_taxonomy_query( $args, $field, $post_id ) {
// modify args
$args['orderby'] = 'count';
$args['order'] = 'ASC';
// return
return $args;
}
add_filter('acf/fields/taxonomy/query', 'my_taxonomy_query', 10, 3);
?>