Home › Forums › Backend Issues (wp-admin) › Saving post meta from ACF directly into DB Doesn't work without update press. › Reply To: Saving post meta from ACF directly into DB Doesn't work without update press.
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,
));
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.