Skip Navigation

[Resolved] Conditionally show distance

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

Problem:
Conditionally show distance

Solution:
You can use the [wpv-conditional] shortcode to display the conditional content based on distance. You can use the shortcode [toolset-maps-distance-value] shortcode to calculate the distance.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/conditionally-show-distance/#post-2296415

Relevant Documentation:
- https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#toolset-maps-distance-conditional-display
- https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#toolset-maps-distance-value

This support ticket is created 2 years, 11 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by MarkJames 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2295627

I am trying to conditionally show the distance.

I have a filter to which allows people to find PAs within a certain distance.

[wpv-control-distance distance_unit_url_param="toolset_maps_distance_unit" distance_radius_url_param="toolset_maps_distance_radius" distance_center_url_param="toolset_maps_distance_center" compare_field="address" default_distance="10" default_unit="mi"]

I am using this shortcode to show the distance.

[toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-address' unit='mi']

I want to add more text around this shortcode and only show it if geocoding is being used.

I have tried registering a custom shortcode i.e. https://toolset.com/forums/topic/display-distance-from-location-on-results/ I registered toolset-maps-distance-value and used the shortcode [wpv-conditional if="( '[toolset-maps-distance-value]' ne '' )"]. I have also tried using toolset_maps_distance_center in a shortcode.

Any help would be appreciated.

Mark

#2296147

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand, you want to display "distance-value" with some text only if user has perform the search with address - is that correct? if yes:

Can you please share problem URL where you added your view as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2296415

I stored it by adding the the following.

[wpv-conditional if="( '[toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-address' unit='mi']' ne '' )"]
Distance: [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-address' unit='mi']miles [/wpv-conditional]

So I used the whole of the shortcode made to show the distance in the conditional.

#2296419

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So, I hope you sorted this already or you still require further help.

#2298761

My issue is resolved now. Thank you!