C
C
CrewCut2016-01-24 19:22:01
WordPress
CrewCut, 2016-01-24 19:22:01

How to change the selection options in the select from AdvancedCustomFields from the front-end?

I use ACF, added select to select a buyer - joxi.ru/82QYbb0t14a042 . It is necessary to use a function through the code to change the elements that can be selected by adding new ones.
How can I do that? Found www.advancedcustomfields.com/resources/dynamically... but I don't understand it, it's not. Lack of English skill

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Игорь Воротнёв, 2016-01-24
@CrewCut

По ссылке это именно оно.

function acf_modify_client_choices( $field ) {

    // $field содержит весь массив данных этого поля 'client'
    // можете сделать var_dump( $field );
    
    // варианты выбора этого поля содержатся в $field['choices']
    // var_dump( $field['choices'] ) покажет что внутри

    // модифицируете данные
    
    // возвращаете обратно
    return $field;
    
}
add_filter('acf/load_field/name=client', 'acf_modify_client_choices');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question