Forum Replies Created
-
AuthorPosts
-
James Cobbett
MemberHi, have you had a chance to look yet?
Thanks,
JamesJames Cobbett
MemberThis reply has been marked as private.James Cobbett
MemberHi,
Thanks for the reply.
There’s nothing in the start address box.
Here’s the link – https://kingdomguide.co.uk/events/
Thanks,
JamesJames Cobbett
MemberIt’s working this morning, so sounds like the query limit has cleared… I’ll keep an eye on it. It’s not actually going to be live on this server, this is just staging so I might not have the problem on the live server.
James Cobbett
MemberI’m using the function now, but it’s still working locally but not on my server. I’m not getting any errors, any ideas?
12345678910111213141516171819202122232425function tribe_events_to_geo( $event_id ) {echo '<h1>EVENT ID</h1>';echo $event_id;global $wpdb;include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );$results = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_EventVenueID" AND post_id = ' . $event_id .'', OBJECT );$venueID = $results[0]->meta_value;$venue_lat = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_VenueLat" AND post_id = ' . $venueID .'', OBJECT );$venue_lng = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_VenueLng" AND post_id = ' . $venueID .'', OBJECT );$address = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_VenueGeoAddress" AND post_id = ' . $venueID .'', OBJECT );$address = $address[0]->meta_value;echo $address;$args = array('map_icon' => '_default.png','post_id' => $event_id, //Post Id of the post'address' => $address // the address we pull from the custom field above);var_dump($args);//make sure the file included and the function needed existsif ( function_exists( 'gmw_pt_update_location' ) ) {gmw_pt_update_location( $args, $force_refresh = false );echo "YEP";}}James Cobbett
MemberIt is shared hosting, maybe it’s to do with that. But if I were to add a post with geo data from the admin panel it works, so i’m not convinced it is that. Surely that would push it over the limit too?
I did try using gmw_pt_update_location(), which is why it’s commented out in my script. But I got:
Fatal error: Call to undefined function gmw_pt_update_location()
Any ideas why I might get that? Do I need to include a gmw script for that to work?
James Cobbett
MemberHi Eyal,
It’s a custom script.
Here’s the full function (sorry, there’s a lot of debugging stuff in it).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100function tribe_events_to_geo( $event_id ) {echo '<h1>EVENT ID</h1>';echo $event_id;global $wpdb;$results = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_EventVenueID" AND post_id = ' . $event_id .'', OBJECT );$venueID = $results[0]->meta_value;$venue_lat = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_VenueLat" AND post_id = ' . $venueID .'', OBJECT );$venue_lng = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_VenueLng" AND post_id = ' . $venueID .'', OBJECT );$address = $wpdb->get_results( 'SELECT * FROM kgwp_postmeta WHERE meta_key = "_VenueGeoAddress" AND post_id = ' . $venueID .'', OBJECT );$address = $address[0]->meta_value;$args = array('map_icon' => '_default.png','post_id' => $event_id, //Post Id of the post'address' => $address[0]->meta_value // the address we pull from the custom field above);$address_apt = $address;//echo 'address_apt ' . $address;if ( is_array( $args['address'] ) ) {echo "<br />HERE<br />";$mulitple_field = true;$address_apt = implode( ' ', $address );unset( $address[ 'apt' ] );$address = implode( ' ', $address );}echo "address " . $address;$geocoded_address = GEO_my_WP::geocoder( $address, 'false' );echo "<br />";var_dump($geocoded_address);$street = $geocoded_address['street'];$apt = $geocoded_address['apt'];$city = $geocoded_address['city'];$state = $geocoded_address['state_short'];$zipcode = $geocoded_address['zipcode'];$country = $geocoded_address['country_short'];echo 'street ' . $street;echo '<br />';echo 'apt ' . $apt;echo '<br />';echo 'city ' . $city;echo '<br />';echo 'state ' . $state;echo '<br />';echo 'zipcode ' . $zipcode;echo '<br />';echo 'country ' . $country;$locationArgs = array('args' => $args,'address' => $address[0]->meta_value,'geocoded' => $geocoded_address);//$LocationArgs = apply_filters( 'gmw_pt_before_location_updated', $locationArgs );//var_dump($LocationArgs);//do_action( 'gmw_pt_before_location_updated', $locationArgs );$featuredPost = ( isset( $_POST['_wppl_featured_post'] ) ) ? $_POST['_wppl_featured_post'] : 0;//Save information to database//global $wpdb;$wpdb->replace( 'kgwp_places_locator', array('post_id' => $locationArgs['args']['post_id'],'feature' => 0,'post_type' => get_post_type( $locationArgs['args']['post_id'] ),'post_title' => get_the_title( $locationArgs['args']['post_id'] ),'post_status' => 'publish','street_number' => ( !empty( $locationArgs['geocoded']['street_number'] ) ) ? $locationArgs['geocoded']['street_number'] : '','street_name' => ( !empty( $locationArgs['geocoded']['street_name'] ) ) ? $locationArgs['geocoded']['street_name'] : '','street' => $street,// //'apt' => $apt,'city' => $city,'state' => $state,'state_long' => $locationArgs['geocoded']['state_long'],// //'zipcode' => $zipcode,'country' => $country,'country_long' => $locationArgs['geocoded']['country_long'],'address' => $address_apt,'formatted_address' => $locationArgs['geocoded']['formatted_address'],//'phone' => $locationArgs['args']['additional_info']['phone'],// 'fax' => $locationArgs['args']['additional_info']['fax'],// 'email' => $locationArgs['args']['additional_info']['email'],// 'website' => $locationArgs['args']['additional_info']['website'],'lat' => $locationArgs['geocoded']['lat'],'long' => $locationArgs['geocoded']['lng'],'map_icon' => $args['map_icon'],));//do_action( 'gmw_pt_after_location_updated', $locationArgs );// var_dump($geocoded_address);//gmw_pt_update_location( $args );}It’s only geocoding query, so i’m not sure why it would go over a query limit? Is there something I can do about this?
Basically I have a location entered into a post type, so I want to get that location from the database, and geocode it so I can search by location.
Thanks your help, this is honestly one of my favourite WordPress plugins and your support is always superb.
-
AuthorPosts