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?
Thanks
Hello,
Please check our document:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#toolset-maps-distance-value
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"]
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153372
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
<br>
with item:@eoi-map.parent -
<br>
[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]
<br>
with item:@eoi-site-connect.parent -
<br>
[wpv-post-body view_template="parent-eoi-info" item="@eoi-site-connect.parent"]
<br>
without item -
<br>
[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.
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
https://toolset.com/faq/provide-supporters-copy-site/
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!