Alternate use (4 posts)

  1. Mattthew
    Posted 2 years ago #

    Any way you can make a plugin to just use the visitor location to show their distant from lat lng meta stored on the post? So it shows how far they are from the post or list of posts on the archive page?


  2. rdconnell
    Plugin Author

    Posted 2 years ago #

    Hi, Sounds like a good idea. I had a quick look and it looks possible to do. Looks like I need to add a couple of custom fields to hold the lat/lng and then display the 'your are xx from this post' text on post the users can see.

    I will give it a go and see what I can do.

    Thanks for the feedback and apologies for the delay in replying, I was on holiday and didn't see your comment until today.

  3. Mattthew
    Posted 2 years ago #

    No apologies! I just had stored the lat long as custom fields and saw this and it seemed a stones throw away. I am working on it now, but using the actual mathematical difference between the numbers to find the distance, as mine are all very local in one small region, we'll see how it goes (having trouble with getting user locations consistently) would love to see what you come up with!

  4. rdconnell
    Plugin Author

    Posted 2 years ago #

    I had a play about and got something working using a geolocation plugin to store the lat/lng in the post and then distancefromme to extract the values and display the distance in a post. There are a couple of minor niggles with the geolocation plugin, for example it doesn't seem to store/display the address text correctly, but it has a nice UI to enter the location details and saved me doing it for now :)

    The plugin creates a space in the post for the text to go and then calls the javascript function to populate it with the correct details. Hopefully you should be able to change the code to use your own custom fields instead if thats more useful.

    The rest of the code is pretty much the same as before as all I did was add the shortcode details to the .php file and modified the distance function in the .js file to accept a source for writing the results back to.

    I noticed the same issue as yourself with the user locations being a bit inconsistent but it generally gives the correct location after the user refreshes the page once. Not the ideal solution but I couldn't find anything better and since this was just for fun I didn't look too hard.

    Hopefully this is useful in what your trying to do as well. If nothing else it was a good idea and I learned some new stuff while doing it so definitely worthwhile :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • DistanceFromMe
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.