Home › Forums › General Issues › Updating Post Values › Reply To: Updating Post Values
Your first error is that when updating post meta using wp_update_post() your meta values need to be in a nested array, example: (see https://developer.wordpress.org/reference/functions/wp_insert_post/)
// Update current post with new preview link
$postInfo = array(
'meta_input' => array(
'field_5cf1142a132e8' => $url
),
'ID' => $postID
);
your second issue is that when updating fields in this manner you’d need to update 2 fields. One using the field name that holds the value and the second is the field key reference. The meta_key of this other field is "_{$field_name}"
and the value of this field is the field key of the field you are updating.
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!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.