Support

Account

Home Forums ACF PRO Google Maps into Taxonomies Reply To: Google Maps into Taxonomies

  • @hube2

    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 😊