You’re pretty close here.. but the object you’ll use to prepopulate the ACF field is the value of the field (for each post), rather than the field itself..
Perhaps something like below:
function my_acf_import_address( $value, $post_id, $field )
// Only do this if there is not a google_map
// value already in this post's fields
if ( empty( $value ) )
// Here I'm assuming the old map function stored
// the address, lat & lng as post meta & not as custom fields
$address = get_post_meta( $post_id, '_job_location', true );
$lat = get_post_meta( $post_id, 'geolocation_lat', true );
$lng = get_post_meta( $post_id, 'geolocation_long', true );
// Now we assign the returned meta values to the
// value array to be returned
$value['address'] = $address;
$value['lat'] = $lat;
$value['lng'] = $lng;
add_filter('acf/load_value/name=google_map', 'my_acf_import_address', 10, 3);
Hope this helps!
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users