Field Render

Display a Taxonomy Terms selector as radio, checkbox or select field type.

Field Group

Field Settings

Setting nameDescription
Allow TaxonomiesFilter which taxonomy can be chosen
Allow TermsFilter which terms of the allowed taxonomies can be chosen
AppearanceSelect the appearance of this field: checkbox, radio or select
Return ValueReturn the terms name, object or ID
Save TermsConnect selected terms to the post
Load TermsLoad value from posts terms
Radio: LayoutChoose the layout: vertical or horizontal
Checkbox: LayoutChoose the layout: vertical or horizontal
Checkbox: ToggleAllow to toggle all values
Select: Allow NullAllow empty value
Select: Select multiple valuesAllow multiple values selection
Select: Stylised UIEnable Select2 UI style
Select: Placeholder TextAppears within the input
Select: Ajax lazy loadUse AJAX to lazy load choices

Field Value

Value can then be retrieved using the common get_field() function. Usage example:

$taxonomy_terms = get_field('taxonomy_terms');

/*
 * Array(
 *      [0] => 12
 *      [1] => 14
 *      [2] => 52
 * )
*/

Custom Query

/*
 * @array        $args     Query arguments
 * @array        $field    Field settings
 * @bool/string  $post_id  Current Post ID
 */
filter('acfe/fields/taxonomy_terms/query',                         $args, $field, $post_id);
filter('acfe/fields/taxonomy_terms/query/name=my_taxonomy_terms',  $args, $field, $post_id);
filter('acfe/fields/taxonomy_terms/query/key=field_5ff50f25a59f6', $args, $field, $post_id);
add_filter('acfe/fields/taxonomy_terms/query/name=my_taxonomy_terms', 'my_acf_taxonomy_terms_query', 10, 3);
function my_acf_taxonomy_terms_query($args, $field, $post_id){
    
    // Change orderby
    // See: https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
    $args['orderby'] = 'count';
    
    // Return
    return $args;

}

Custom Result

/*
 * @string       $text     Term name result
 * @array        $term     Term object
 * @array        $field    Field settings
 * @bool/string  $post_id  Current Post ID
 */
filter('acfe/fields/taxonomy_terms/result',                         $text, $term, $field, $post_id);
filter('acfe/fields/taxonomy_terms/result/name=my_taxonomy_terms',  $text, $term, $field, $post_id);
filter('acfe/fields/taxonomy_terms/result/key=field_5ff50f25a59f6', $text, $term, $field, $post_id);
add_filter('acfe/fields/taxonomy_terms/result/name=my_taxonomy_terms', 'my_acf_taxonomy_terms_result', 10, 4);
function my_acf_taxonomy_terms_result($text, $term, $field, $post_id){
    
    // Change term name result
    $text = "<strong>{$text}</strong>";
    
    // Return
    return $text;

}