Support

Account

Home Forums Front-end Issues ACF Load Post – Flexible Content – Not showing up on front end until manual save Reply To: ACF Load Post – Flexible Content – Not showing up on front end until manual save

  • I could be wrong, my code I was looking at adds layouts to the array without adding content to any of the fields assuming that they will all be populated with values added as defaults for each sub field.

    What I do is return an array of layout names.

    
    /Prepop Initial Notes
    add_filter('acf/load_value', 'add_starting_flex', 1, 3);
        function  add_starting_flex($value, $post_id, $field) {
        if ($field['key'] != 'field_5eb8736d02e62' || $value !== NULL) {
          return $value;
        }
    
            // add default layouts
            $value = array('layout_note_text', 'layout_video_note');
             return $value;
       
    }
    

    The reason that this works is because at this point in the execution the flex field value is just an array of layout names. When ACF then filters this it populates subfields with default values.