Post Location Function Not Working
-
Hi team,
We are using the gmw_update_post_location function to update GMW location of posts as per instructed.
However, it is not working. Can you help check out code?
Thanks.function gmw_update_post_type_model_location( $post_id ) { // Return if it's a post revision. if ( false !== wp_is_post_revision( $post_id ) ) { return; } // check autosave. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // check if user can edit post. if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } // get the address from the custom field "address". $map_location = get_post_meta( $post_id, 'map_location', true ); $location = get_post_meta( $post_id, 'location', true ); $area = get_post_meta( $post_id, 'area', true ); $base_city = get_post_meta( $post_id, 'base_city', true ); If ($map_location != '') { $address = $map_location; } else { $address = $location.', '.$area.', '.$base_city; } // varify that address exists. if ( empty( $address ) ) { return; }; // verify the updater function. if ( ! function_exists( 'gmw_update_post_location' ) ) { return; } //run the udpate location function gmw_update_post_location( $post_id, $address ); } //execute the function whenever post type is being updated add_action( 'save_post_model', 'gmw_update_post_type_model_location' ); add_action( 'acf/save_post', 'gmw_update_post_type_model_location' );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Post Location Function Not Working’ is closed to new replies.