Support

Account

Home Forums ACF PRO Update_field works a bit strange with new_post Reply To: Update_field works a bit strange with new_post

  • Hi @hube2

    Thanks for ur advise always!
    I should have read the doc well…

    Then I tried this code below

    $my_post = […];
    $post_id = wp_insert_post( $my_post );
    $field = get_field_object(‘selector’, $post_id );
    Update_field($field[‘key’], ‘value’, $post_id);

    but $field is empty, so Update_field() does not work.

    Do I have to use SQL instead of get_field_object()
    to get field_key from field_name in case of a new post?