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