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’re working hard on Advanced Custom Fields PRO 6.0, and Beta 1 is now available 🚀
— Advanced Custom Fields (@wp_acf) August 12, 2022
Featuring improved performance for Repeater fields with large datasets, and a new generation of ACF Blocks.
Let’s take a look 🧵https://t.co/Befre3kFAo
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.