acf_field_taxonomy::render_field_select
Create the HTML interface for your field
Method of the class: acf_field_taxonomy{}
No Hooks.
Returns
null. Nothing (null).
Usage
$acf_field_taxonomy = new acf_field_taxonomy(); $acf_field_taxonomy->render_field_select( $field );
- $field(required)
- .
Changelog
| Since 3.6 | Introduced. |
acf_field_taxonomy::render_field_select() acf field taxonomy::render field select code ACF 6.0.4
function render_field_select( $field ) {
// Change Field into a select
$field['type'] = 'select';
$field['ui'] = 1;
$field['ajax'] = 1;
$field['choices'] = array();
// value
if ( ! empty( $field['value'] ) ) {
// get terms
$terms = $this->get_terms( $field['value'], $field['taxonomy'] );
// set choices
if ( ! empty( $terms ) ) {
foreach ( array_keys( $terms ) as $i ) {
// vars
$term = acf_extract_var( $terms, $i );
// append to choices
$field['choices'][ $term->term_id ] = $this->get_term_title( $term, $field );
}
}
}
// render select
acf_render_field( $field );
}