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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.