Skip Navigation

[Waiting for user feedback] Toolset Distance not working

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 4 replies, has 1 voice.

Last updated by Christopher Amirian 1 hour, 59 minutes ago.

Assisted by: Christopher Amirian.

Author
Posts
#2846027
aCapture.PNG

On this page: hidden link

I added distance on the view list.

I used this code:

<div class="distance"><b>Distance:</b> [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-clinic-map-address' unit="km" decimals='0'] km</div>

But it doens't work in front end. Previosly its working before but suddenly its not working anymore. I'm tired what the issue was, as all correctly setup.

When I input location on the search tab to find nearest location, it doesn't work as well.

Can you help me pls?

View Name: General Booking Location

#2846065

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. From the code of the view I cncluded the points below:

Your address-field key is inconsistent: compare_field="clinic-map-address" vs postmeta="wpcf-clinic-map-address"

In your filter you have:

[wpv-control-distance ... compare_field="clinic-map-address" ...]

But in the loop you calculate distance with:

[toolset-maps-distance-value ... postmeta='wpcf-clinic-map-address' ...]

Distance shortcode expects the actual address field slug (stored in postmeta as wpcf-<slug> for Types fields).

Go to Toolset → Custom Fields (or Types field group) and confirm the real slug of your Address field.

Then make the View consistent, e.g. if the slug is clinic-map-address, the stored meta key is typically:

wpcf-clinic-map-address

So update your distance control to match that:

[wpv-control-distance ... compare_field="wpcf-clinic-map-address" ...]

Also test without wpcf too clinic-map-address

One more thing that can break your layout/JS: broken quotes

You currently have:

<a href="<em><u>hidden link</u></em> field='clinic-location'][/types] target="_blank"">

That’s malformed HTML (the target="_blank" is inside the href attribute). This can mess up the DOM and sometimes “randomly” affect what appears after it in the loop.

Fix it like:

<a href="<em><u>hidden link</u></em> field='clinic-location'][/types]" target="_blank">

Finally please register toolset-maps-distance-value in WP Admin → Toolset → Settings → Front-end Content → Third-party shortcode arguments.

Thanks.

#2846124
reg.PNG
1.PNG
2.PNG

Hi, thanks for your response!

I already follow your instruction but still doesn't work

1. I've update the filter code to:

[wpv-control-distance default_distance="200" compare_field="wpcf-clinic-map-address" distance_center_url_param="toolset_maps_distance_center" distance_radius_url_param="toolset_maps_distance_radius" distance_unit_url_param="toolset_maps_distance_unit" inputs_placeholder=" %%DISTANCE%% %%CENTER%%"]

2. I've update the achor link to:

<span>hidden link field='clinic-location'][/types]" target="_blank">[types field='clinic-location'][/types]</span>

3. I already registered the "toolset-maps-distance-value"

See screenshot.

I made all changes but unfortunately, still doesn't work on the front-end. PLS HELP ME!

#2846149

sorry I mean for the 2:, I already fixed the url:

2. I've update the achor link to:

<span>hidden link field='clinic-location'][/types]" target="_blank">[types field='clinic-location'][/types]</span>

#2846227

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Thank you. I spent a lot of time and I could not figure out what the problem might be with the code.

I wonder if it is possible with you to start from scratch with a clear mind as a test without extra bells and whistles. Please follow this:

https://toolset.com/documentation/legacy-features/maps-plugin/filtering-and-ordering-map-markers-by-distance/

See if it works on that case?

Or you can consider using blocks as a test:
https://toolset.com/course-lesson/filtering-and-ordering-map-markers-by-distance/

Thanks.