Skip Navigation

[Résolu] How to set default distance and unit using toolset maps distance filter

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How to set default distance and unit using toolset maps distance filter

Solution:
You can use attribute default_distance and default_unit with maps distance filter shortcode [wpv-control-distance] to set default default distance and unit.

For example:

[wpv-control-distance default_distance="20" default_unit="mi" compare_field="town" 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="Within 20 miles of %%CENTER%%"]

Relevant Documentation:

This support ticket is created Il y a 6 années et 4 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 3 réponses, a 3 voix.

Dernière mise à jour par martinD-7 Il y a 6 années et 4 mois.

Assisté par: Minesh.

Auteur
Publications
#957103

I'm concerned that there is no restriction on the value users can enter for the 'search within' value. This means a user could enter, for example, 1000 miles and return every single post from my database. Not good from the point of view of server load or giving a competitor valuable information about my customers!!!

So I have the following questions:-

How do I remove the ability to for users to change the default distance value on the frontend?

OR

How do I restrict the number of posts returned?

If you can suggest a different or better solution, I'm all ears.

Thank you

#957218

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can adjust the attribute inputs_placeholder to remove the distance input textbox.

For example:

inputs_placeholder="Show results within of %%CENTER%%"

Full shortcode example:

[wpv-control-distance compare_field="your-field" 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="Show results within of %%CENTER%%"]

To set default distance radius - you can edit the distance query filter as shown with the following image:
=> lien caché

#957240

Played around with your shortcode but no posts being returned. I re-added the shortcode using the 'new filter' button and for some reason the shortcode it produced added the default distance value like this:-

[wpv-control-distance default_distance="20" default_unit="mi" compare_field="town" 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="Within 20 miles of %%CENTER%%"]

and now it works!

Excellent - thank you ?

#1221173

Hi There.

is it possible only to show KILOMETERS and having NO dropdown with km AND miles? We do not need miles in Germany.
Thanks