Home › Forums › Add-ons › Flexible Content Field › Load flexible content field from setting page › Reply To: Load flexible content field from setting page
I got this working, here is the code encase anybody has the same problem:
function copy_Dev_settings( $field ) {
if ( is_edit_page(‘new’) ) { // only populate for new posts
//echo “this is a new post!! <br />”;
if( have_rows(‘deliverables’, ‘option’ )){ // if there are values on the settings page for this option
$value = array();
while ( have_rows(‘deliverables’, ‘option’) ) : the_row(); //starting at a specific row
if( get_row_layout() == “new_deliverable” ){ //set the layout for the flexible content field
$acf_fc_layout = ‘new_deliverable’; //set the values for layout and each sub field
$deliv = get_sub_field(‘deliverables’);
$days = get_sub_field(‘days’);
if ( $acf_fc_layout == ‘new_deliverable’ ) { // apply the values to the correct layout and fields using the key value for that sub field
$value[] = array(
‘acf_fc_layout’ => $acf_fc_layout,
‘field_5d0c21f3e31e1’ => $deliv,
‘field_5d0c220ce31e2’ => $days
);
}
}
else {
echo “cannot find development deliverables row layout”;
//echo “<br />”;
}
endwhile;
$field[‘value’] = $value; //assign the values to the field value array
}
else
echo “nothing”;
}
return $field; //return the full field array to the page/post etc
}
add_filter(‘acf/load_field/key=field_5d0b74c37ad29’, ‘copy_Dev_settings’);
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.