Turned out it was a plugin causing it to break! Called ‘Advanced Floating Content’ in case anybody else runs into this issue!
It worked! I had no idea this function existed… do you mean a script in ACF or in WP?
No that’s fine, thanks for replying, i appreciate it 🙂
I think the process of this working, will be very useful for me moving forward, as i want to auto populate some fields etc, so gonna see just how it works for ‘options page’ fields.
For others i worked out the solution.
So essentially you use the update_field, then update_post.
Example:
// Flexible element
$fc_key = "field_key_for_flexible_content";
// build the rows to insert
$fc_rows = array(
array(
'field_key_for_field_inside_flexible_layout' => '',
'acf_fc_layout' => 'name_of_layout_inside_flexible_item'
),
array(
'field_key_for_field_inside_flexible_layout' => '',
'acf_fc_layout' => 'name_of_layout_inside_flexible_item'
),
);
// run the update
update_field( $fc_key, $fc_rows, $post_id );
// update
wp_update_post( array (
'ID' => $post_id,
));
I’ve created a plugin which does a ‘fresh sync’ from an API, which destroys the old posts, and re-creates them. I then want to make a generic structure to be placed back in by default.
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.