Support

Account

Home Forums Backend Issues (wp-admin) A filter for taxonomy field

Solved

A filter for taxonomy field

  • Hello Elliot,

    I have a very simple task: a taxonomy field to show in admin a list consisting from only few terms of the taxonomy, not all. So far I wasn’t able to find a filter by which it would be possible to change taxonomy request. Is there any way to achieve this?

    Thanks!

  • Hi @wpUXsolutions

    Looking at the taxonomy field type file, on line 205 you will see this line of code:

    
    // vars
    		$args = array(
    			'taxonomy'     => $field['taxonomy'],
    			'hide_empty'   => false,
    			'style'        => 'none',
    			'walker'       => new acf_taxonomy_field_walker( $field ),
    		);
    		
    		$args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field );
    

    Using this filter, you can customize the $args. These $args are later used on line 238 in the function wp_list_categories. If you check out this function on WordPress, you will see that there are some params which ‘exclude’.

    Thanks
    E

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘A filter for taxonomy field’ is closed to new replies.