Support

Account

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,
    ));