Display a Taxonomy Terms selector as radio, checkbox or select field type.
Setting name | Description |
Allow Taxonomies | Filter which taxonomy can be chosen |
Allow Terms | Filter which terms of the allowed taxonomies can be chosen |
Appearance | Select the appearance of this field: checkbox, radio or select |
Return Value | Return the terms name, object or ID |
Save Terms | Connect selected terms to the post |
Load Terms | Load value from posts terms |
Radio: Layout | Choose the layout: vertical or horizontal |
Checkbox: Layout | Choose the layout: vertical or horizontal |
Checkbox: Toggle | Allow to toggle all values |
Select: Allow Null | Allow empty value |
Select: Select multiple values | Allow multiple values selection |
Select: Stylised UI | Enable Select2 UI style |
Select: Placeholder Text | Appears within the input |
Select: Ajax lazy load | Use AJAX to lazy load choices |
$taxonomy_terms = get_field('taxonomy_terms');
/**
* array(
* 'term_id' => 24,
* 'name' => 'Term 1',
* 'slug' => 'term-1',
* 'term_group' => 0,
* 'term_taxonomy_id' => 24,
* 'taxonomy' => 'my-taxonomy',
* 'description' => '',
* 'parent' => 0,
* 'count' => 2,
* 'filter' => 'raw',
* )
*/
$taxonomy_terms = get_field('taxonomy_terms');
// Term 1
$taxonomy_terms = get_field('taxonomy_terms');
// 24
$taxonomy_terms = get_field('taxonomy_terms', false, false);
// 24
/**
* acfe/fields/taxonomy_terms/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;
}
/**
* acfe/fields/taxonomy_terms/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;
}