Support

Account

Home Forums Backend Issues (wp-admin) Get values from repeater field to select field for every post dynamically

Unread

Get values from repeater field to select field for every post dynamically

  • Hello,

    I’m trying get values from a repeater value and use these values in select field.
    Both fields are in custom post type and repeater field’s values changes for every post.

    Fields look like this.
    https://prnt.sc/wmhpdx

    And my function code is like this.

    function acf_load_marke_name_field_choices($field)
        {
    
            if( have_rows('applicable_products') ) {
            
                // while has rows
                while( have_rows('applicable_products') ) {
                    
                    // instantiate row
                    the_row();
                    
                    // vars
                    $label = get_sub_field('applicable_product_name');
                    
                    $field['choices'][ $label ] = $label;
        
                }
            
            }
            return $field;
        }
        
        add_filter('acf/load_field/key=field_5ffc592f83066', 'acf_load_marke_name_field_choices');

    How should I change the code, so I can get values from repeater fiels to select field differently for every custom post.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.