How to calculate & show distance between a users geolocation and post location
-
Hi WordPressers,
This is my first post. I have been using WP for a year, only using pre-made themes and plugins (the easy life!). I am now trying to learn php/js and be able to customize my own sites as I want them. But i am still a complete rookie!
I am trying to create a directory of businesses. I have created the CPT ‘Business’ with the taxonomies ‘location’ & ‘type’. I have added some custom fields of ‘address’, ‘longitude’ and ‘latitude’ for this post type also.
Now, the aim is to calculate the USERS distance from each business (in meters/kilometers).
The distance should then be displayed in the new CPT templates i created, archive-business.php (for category listings) and single-business.php (for the individual business pages). So, for every business that the user sees on the site, they can see how far away it is from them.
Straightforward? Hopefully for someone out there ??
I have tried a number of plugins that are unsuitable, and unsuccessfully tried to adapt some code tutorials on the web. As i am trying to learn, the plugin route is not a way I want to go, so if anyone can help me code this, it is much appreciated!
Thanks,
Tommy
- The topic ‘How to calculate & show distance between a users geolocation and post location’ is closed to new replies.