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?
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.