acf_get_choices_from_terms()
acf_get_choices_from_terms
Returns an array of choices from the terms provided.
Хуков нет.
Возвращает
Массив
.
Использование
acf_get_choices_from_terms( $terms, $format );
- $terms (обязательный)
- -
- $format(строка)
- The value format (term_id, slug).
По умолчанию: 'term_id'
Список изменений
С версии 5.7.5 | Введена. |
Код acf_get_choices_from_terms() acf get choices from terms ACF 6.0.4
function acf_get_choices_from_terms( $terms, $format = 'term_id' ) { // vars $groups = array(); // get taxonomy lables $labels = acf_get_taxonomy_labels(); // convert array of encoded strings to terms $term = reset( $terms ); if ( ! $term instanceof WP_Term ) { $terms = acf_get_encoded_terms( $terms ); } // loop over terms foreach ( $terms as $term ) { $group = $labels[ $term->taxonomy ]; $choice = acf_get_choice_from_term( $term, $format ); $groups[ $group ][ $choice['id'] ] = $choice['text']; } // return return $groups; }