Support

Account

Home Forums ACF PRO load_fields with cloned fields Reply To: load_fields with cloned fields

  • Yeah sorry, I should’ve included anyway! The code is as follows:

    function acf_load_anchor_points( $field ) {
        
        $post_id = get_the_ID();
    
        // if has rows
        if (have_rows('blocks', $post_id)):
            
            // reset choices
            $field['choices'] = array();
            
            // while has rows
            while (have_rows('blocks', $post_id)): the_row();
                
                if (get_row_layout() ==  'anchor_point'):
                    $title = get_sub_field('title');
                    $slug = sanitize_title($title);
                    $field['choices'][ $slug ] = $title;
                endif;
                
            endwhile;
            
        endif;
    
        // return the field
        return $field;
        
    }
    add_filter('acf/load_field/key=field_57a9b1c80a552', 'acf_load_anchor_points');