acf/fields/taxonomy/wp_list_categories

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.

  1. acf/fields/taxonomy/wp_list_categories – filter for every field
  2. acf/fields/taxonomy/wp_list_categories/name={$field_name} – filter for a specific field based on it’s name
  3. acf/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);

?>

Related

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.