acf_get_choice_from_term()
acf_get_choice_from_term
Returns an array containing the id and text for this item.
No Hooks.
Returns
Array.
Usage
acf_get_choice_from_term( $term, $format );
- $term(required)
- .
- $format(string)
- The value format (term_id, slug).
Default:'term_id'
Changelog
| Since 5.7.6 | Introduced. |
acf_get_choice_from_term() acf get choice from term code ACF 6.8.8
function acf_get_choice_from_term( $term, $format = 'term_id' ) {
// vars
$id = $term->term_id;
$text = acf_get_term_title( $term );
// return format
if ( $format == 'slug' ) {
$id = acf_encode_term( $term );
}
// return
return array(
'id' => $id,
'text' => $text,
);
}