Skip Navigation

[Resolved] Geographical Filter by Countries and States

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

Problem: Is it possible to filter a View by country or state if the location is managed in an address custom field? Is there a template available for creating country and state inputs?

Solution: You must create separate country and state custom fields to be able to filter a View by those criteria. Other Users have created modules of geographical criteria, but there is nothing built-in to Toolset.

Relevant Documentation:
https://toolset.com/forums/topic/separating-content-from-the-address-field/
https://toolset.com/forums/topic/how-to-import-states-and-countries-into-selects-for-fields/

This support ticket is created 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1168711

We want to establish a list of artist residencies, which means that artists get accommodation and/or studio for a given time at a given place. Some residencies are offered by the institutions at the residency location (XY Residency Foundation), others are offered by foundations with a national or regional scope.

Therefore, to make the list work for searching and filtering, we need to add geographical codes to the entries, on two sides:
a) place of residency ("I am looking for a residency in country X"), and
b) place of the applicant ("I live in the state of Y, for which residencies can I apply?")

This leads me to two questions on Toolset:
a) with regard to exact locations, which can be located on a map with Google or Bing, is there a way to search/filter the results e.g. by country, or state, if there is only the geolocation/maps field filled in? (or are additional fields for country/state necessary?)
b) Is there a "template" for a geographical repository, where the user can select/deselect countries and also states therein?

I am thankful for any hint!

#1169026

Hi, I'll be glad to give you some additional information.

a) with regard to exact locations, which can be located on a map with Google or Bing, is there a way to search/filter the results e.g. by country, or state, if there is only the geolocation/maps field filled in? (or are additional fields for country/state necessary?)
There is no way to filter by country or state if a single Types Address field is used to store the location. It would require additional fields for country / state / region and so on. Types address fields do not automatically separate this information for you, but another ticket in the forum shows an example of how you can use custom code to split individual pieces into separate fields: https://toolset.com/forums/topic/separating-content-from-the-address-field/

b) Is there a "template" for a geographical repository, where the user can select/deselect countries and also states therein?
There's nothing built-in to Toolset, but other Users have created custom modules for this purpose. You can use Toolset Module Manager to import their work as a starting point. Check the link here for more information: https://toolset.com/forums/topic/how-to-import-states-and-countries-into-selects-for-fields/

#1169865

Thank you – I obviously searched for the wrong search terms, so thank you for guiding me to the relevant forum entries!

#1306683

It seems that we cannot make it work – is the description at https://toolset.com/forums/topic/separating-content-from-the-address-field/ still valid, or has there been some changes in the meantime?

Thank you!

#1306885

Yes, it is still the case that you must use custom JavaScript to parse the geocoded results from the Maps API, then use custom code to separate those elements into your desired custom fields. It's an advanced technique that requires knowledge of JavaScript and PHP.