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 wp_list_categories documentation.
Changelog
- Limited to ‘checkbox’ and ‘radio’ appearance setting in v5.0.0
- Added name and key variants in v5.0.0
- Added in v4.0.0
Parameters
Name | Type | Description |
---|---|---|
$args | array | An array of arguments passed to the wp_list_categories function |
$field | array | An array containing all the field settings |
Usage
There are 3 ways to hook into acf/fields/taxonomy/wp_list_categories
filter.
acf/fields/taxonomy/wp_list_categories
– filter for every fieldacf/fields/taxonomy/wp_list_categories/name={$field_name}
– filter for a specific field based on it’s nameacf/fields/taxonomy/wp_list_categories/key={$field_key}
– filter for a specific field based on it’s key
functions.php
<?php
function my_taxonomy_wp_list_categories( $args, $field ) {
// modify args
$args['orderby'] = 'count';
$args['order'] = 'ASC';
// return
return $args;
}
add_filter('acf/fields/taxonomy/wp_list_categories', 'my_taxonomy_wp_list_categories', 10, 2);
?>