Skip Navigation

[Resolved] How i add location?

This support ticket is created 5 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/Karachi (GMT+05:00)

Author
Posts
#1196985

Hello I'm trying to understand how I can add the locations. I need to create a manual, perfect and complete system. I need to know how to create three levels of locations. (Region, Province, City) Only Italy.

So I have to manually enter all locations. But then I want to insert the function in the form in the frontend and make sure that or select in dropdown first the Region then load the provinces of that region and finally load the cities of the selected province. Or a single box where you can only enter the city and that is ajax style ie that while writing the first letters load the results and then select the city directly.

The Region and the provinces I need for the final structure of the site, for the filters etcetera but also for a question of seo and slug of the various permalinks.

Can you help me in this?

#1197196

Hi Antonio,

Thank you for contacting us and I'll be happy to assist.

To efficiently store three levels of locations (Region, Province & City) and link them with one another, in a hierarchal order, you can follow these steps:

1. You'll register three different custom post types, one for each type of location, i.e.:

a). Region
b). Province
c). City

2. To connect these 3 types of locations with one another, you'll need two post-relationships.
https://toolset.com/documentation/post-relationships/

a). A one-to-many relationship between the "Regions" and "Provinces".
(which means, each region can have multiple provinces)

b). A one-to-many relationship between the "Provinces" and "Cities".
(which means, each province can have multiple cities)

Once, you've structured your location items like this, you'll be able to use Toolset Form, to add them from the front-end, step-by-step (i.e. Region -> Province -> City).

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1197463

Ok perfect to achieve what I need. But I have another doubt. In the frontend, when inserting a new post I would like there to be a text box for example with ajax search, so that the user can type only the province or the city. However, the announcement will also be linked to the region of the chosen city.

first of all I wanted to know if I have to create a "relationship form"?

I have created custom posts for regions, provinces and cities but I do not know how to insert them in the form
For example, I'll give you an Italian example:

Region: Campania
Province: Napoli
City: Casoria

If user X inserts a new post, I want to create only one form in the form where he can only enter the name of his city or his province, he can not enter the region.

However, if the user enters the new CASORIA post as the locality, then if you look for postings in CAMPANIA or NAPOLI in the search, there will also be posts published in CASORIA.

So the user can not choose the region to place ads, but regions can be searched by post search.

#1197683

Hi Antonio,

Yes, you can accomplish that and the front end forms and the search filters work independently from each other.

Important note: If your goal is to associate posts with the locations objects that we've discussed, you'll need a 4th custom post type, which can be named as "Listings". This will hold all the actual posts that you would like to store from users.

You'll also need, one more "one-to-many" relationship between the "Cities" and "Listings".
(which means, each city can have multiple listings)

While working with the front-end form to add a new listing, a user will only need to specify which "City" this particular "Listing" belongs to. The above connections ( City -> Province -> Region ) will naturally hold.

For the search filters, a visitor will be able to narrow search results of listings by each level. Which means he/she can look for listings in an entire region or make the search more specific by selecting a province or even a city.

I'll recommend to practically experiment what we've discussed here and for each new question/concern, start a new ticket, to keep things simple and clutter-free.

regards,
Waqar