Last active
January 9, 2020 15:29
-
-
Save remcotolsma/50c9999b3c1a36d5cc98d47473d7f937 to your computer and use it in GitHub Desktop.
Geocode providers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define( 'WP_USE_THEMES', false ); | |
require './wp-blog-header.php'; | |
$query = new WP_Query( | |
array( | |
'post_type' => 'provider', | |
'nopaging' => true, | |
) | |
); | |
$number = 0; | |
if ( $query->have_posts() ) { | |
while ( $query->have_posts() ) { | |
$query->the_post(); | |
$post_id = get_the_ID(); | |
$address = get_post_meta( $post_id, '_pronamic_google_maps_address', true ); | |
echo $post_id, ' - ', get_the_title(), ' - ', $address, '<br />'; | |
if ( empty( $address ) ) { | |
$street = get_post_meta( $post_id, 'coopdichtbij_provider_address', true ); | |
$postal_code = get_post_meta( $post_id, 'coopdichtbij_provider_postal_code', true ); | |
$city = get_post_meta( $post_id, 'coopdichtbij_provider_city', true ); | |
$address .= $street . "\r\n"; | |
$address .= $postal_code . ' ' . $city; | |
$address = trim( $address ); | |
echo 'Address: ', $address, '<br />'; | |
if ( ! empty( $address ) ) { | |
update_post_meta( $post_id, '_pronamic_google_maps_address', $address ); | |
$number++; | |
} | |
} | |
$active = get_post_meta( $post_id, '_pronamic_google_maps_active', true ); | |
$geocode_status = get_post_meta( $post_id, '_pronamic_google_maps_geocode_status', true ); | |
if ( empty( $active ) && 'OK' === $geocode_status ) { | |
update_post_meta( $post_id, '_pronamic_google_maps_active', 'true' ); | |
} | |
} | |
} | |
echo '<br />'; | |
echo 'Number: ', $number; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment