Viewing 1 replies (of 1 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    If you want to get the distance for a single location, then you first have to calculate it.

    How this is normally done is that the passed location is converted into a set of coordinates, those coordinates are then used in a SQL query that searches through the DB for any locations that fall within the set search radius, and this produces a list of matching locations with the distance to each location.

    What you need to do if you want to do this for a single location is to first send the zip to the Geocode API which you can do like this.

    $latlng = wpsl_get_address_latlng( 'your zip code' );

    The part that is more work is to use the coordinates in the SQL query. You can’t just call it through a single function ( maybe I should change this in the future ), so you will have to copy the code ( the SQL query itself is on line 249 ) that normally handles the search, and modify it to do so.

    If something isn’t clear, then let me know ( I assume you’re comfortable with code? ).

Viewing 1 replies (of 1 total)
  • The topic ‘Pass zip in to GET to get distance’ is closed to new replies.