Home › Forums › ACF PRO › Map/post ACF field to meta_key value where meta_key field has multiple values › Reply To: Map/post ACF field to meta_key value where meta_key field has multiple values
Using a select that allows multiple values is a good choice it holds arrays in the database and it’s probably the easiest field to deal with. ACF stores these fields as serialized array.
You already have the values populated into the acf field by your comment, so putting them back into the other fields you would do something like this.
add_action('acf/save_post' 'update_cptonomies_field_name');
function update_cptonomies_field_name($post_id) {
$values = get_field('acf_field_name', $post_id);
delete_post_meta($post_id, 'cptonomies_field_name');
if ($values) {
foreach ($values as $value) {
add_post_meta($post_id, 'cptonomies_field_name', $value, false);
}
}
}
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.