Skip Navigation

[Resolved] Maps distance filter using a custom field as the location

This thread is resolved. Here is a description of the problem and solution.


Get the distance value from related "EOI" post(current-client-address field) and related "site" posts(site-address field).


You can follow our document to customize the [toolset-maps-distance-value] shortcode, for example:

Relevant Documentation:

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by stuart 2 years, 9 months ago.

Assisted by: Luo Yang.


I am trying to use the following shortcode to get the distance from a location that is stored on the parent (this is the primary, or location I wish to measure from).

I am then within a view loop on the child post looking at the child location value post-meta custom field.
Like this below - I have also tried it with a short-code, but this didnt work.

[toolset-maps-distance-value location="current-client-address' item='@eoi-map.parent'" postmeta='wpcf-site-address']

What could I be doing wrong here?




Please check our document:
The shortcode [toolset-maps-distance-value] does not support item attribute

In your case, you can create a content template, for example "parent-eoi-info", in the content display the shortcode without item attribute:
[toolset-maps-distance-value location="current-client-address' postmeta='wpcf-site-address']

In view's loop, display above content template shortcode with item attribute, for example:
[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]


Unfortunately that didn't work... this is what I tried to test the combinations... you may need a duplicator backup (its local).

Content Template: parent-eoi-info

map:[toolset-maps-distance-value location='current-client-address' postmeta='wpcf-site-address'] END.
<br>Dev Site address: [types field='site-address'][/types] END.
<br>Client Address[types field='current-client-address'][/types] END.

VIEW - in-between markers

with item:@eoi-map.parent -
[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]
with item:@eoi-site-connect.parent -
[wpv-post-body view_template="parent-eoi-info" item="@eoi-site-connect.parent"]
without item -
[wpv-post-body view_template="parent-eoi-info"]

RESULTS on front end:

with item:@eoi-map.parent -

with item:@eoi-site-connect.parent -
map: END.
Dev Site address: END.
Client AddressOatlands Crescent, Oatlands NSW, Australia END.
without item -
map: END.
Dev Site address: 10 Eastern Creek Drive, Eastern Creek NSW, Australia END.
Client Address END.

New threads created by Jamal and linked to this one are listed below:


Please provide the duplicator package, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks


Thanks for the details, I am downloading the files, will update here if find anything


Your website settings are very complicated, the problem page URL you mentioned above is a single "Map" post.

Are you going to compare get the distance value from related "EOI" post(current-client-address field) and related "site" posts(site-address field)?

Please confirm it first, thanks


That is correct.

The 'Map' page is going to contain the view that displays the data from parent EOI (address of the head office), the 'sites' are proposed locations the business may like to move too.

Therefore I would like to compare the businesses current location (EOI Current Client Address, on the EOI CPT) to all of the 'Sites' ( Site Address'es) on the 'Map' page.

There may be a better way of organising this but this is what I came up with 🙂

The 'Map' page will be shared with each client so they can decide based on the distance from their current office to their new proposed offices.

Thanks Luo


Thanks for the confirmation, please try these:
1) Create a post view "child-site-posts":
- Query "Sites" posts
- Filter by post relationship or repeatable fields group owner:
Select posts in a EOIs Sites relationship that are a related to the current post in the loop.
- In views loop, display the distance shortcode like this:

[toolset-maps-distance-value location='[types field="current-client-address" item="@eoi-site-connect.parent"][/types]' postmeta='wpcf-site-address']

Here you can display more information of "Sites" posts

2) Edit the content template "parent-eoi-info"
hidden link
Display above view's shortcode, like this:

[wpv-view name="child-site-posts"]

3) Edit the content template "Template for Maps":
hidden link
Add a shortcode block, display above content template shortcode, like this:

[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]

Then test the single "Maps" post in frontend, it works fine in my localhost.


My issue is resolved now. Thank you!

This worked a treat, I could also use: [toolset-maps-distance-value location='[types field="current-client-address" item="@eoi-site-connect.parent"][/types]' postmeta='wpcf-site-address']

on the initial view between the Markers to get the distance on the popup perfectly.

Thanks again!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.