Home › Forums › ACF PRO › Google Maps into Taxonomies › Reply To: Google Maps into Taxonomies
I think I made it.
function my_copy_date_filter( $post_id ) {
$post_type = get_post_type( $post_id );
if ( $post_type != 'spot' ) {
return;
}
$location = get_field( 'spot_location', $post_id );
if( $location[ 'lat' ] && $location[ 'lng' ] ) {
update_post_meta( $post_id, 'spot_coordinates', $location[ 'lat' ].','.$location[ 'lng' ] );
}
if( $location[ 'address' ] ) {
update_post_meta( $post_id, 'spot_address', $location[ 'address' ] );
}
if( $location[ 'state' ] ) {
wp_set_object_terms($post_id, $location[ 'state' ], 'bundesland', false);
}
if( $location[ 'city' ] ) {
wp_set_object_terms($post_id, $location[ 'city' ], 'ort', false);
}
if( $location[ 'post_code' ] ) {
wp_set_object_terms($post_id, $location[ 'post_code' ], 'postleitzahl', false);
}
}
add_filter( 'acf/save_post', 'my_copy_date_filter', 20 );
It inserts new Terms related to the 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.