Skip Navigation

[Resolved] Add list of countries to custom post group

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 8 replies, has 2 voices.

Last updated by Minesh 10 months ago.

Assisted by: Minesh.

Author
Posts
#2690364
2024-04-01_15-24-13.png
fieldgroup.png

Tell us what you are trying to do?
I want a country field people can use to filter my map of projects.
It appears that a drop-down is not available for some reason (not allowed). You will see currently Im using a single line of text but that leaves the possibility of people spelling a country wrong and having multiples of the same country listed in the map.

Is there any documentation that you are following?
I tried to copy https://discover-wp.com/site-types/gyms-and-trainers/
It would be preferrable if we could add the country of the address field as a drop-down to sort by.
I actually don't see any way in the post editor to modify what I copied over from gyms demo.

What is the link to your site?
The site is private, in development. I can send login if needed

#2690498

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know - how you want to setup the Country field? With Gym demo site the Country dropdown is setup as post type - then you can setup Country as post type.

Once you setup Country as custom post type then create post relationship with Country and your desired post type and connect the posts:
- https://toolset.com/course-lesson/what-are-post-relationships-and-how-they-work/

Please check the following Doc:
- https://toolset.com/documentation/legacy-features/views-plugin/how-to-filter-by-related-posts/
- https://toolset.com/lesson-placement/lesson-placements-1622935-1621213/#how-to-search-by-post-relationships

#2690566

Im not sure about all that. My custom post type is projects ( or gyms). Each project was performed at an address - that is what puts it on the map. and I want people to filter the map by country. I don't see why I would have to create a second post type called country and attach that to my project post type. Thats a lot of work to just get the country field to not be a single text field.

#2690569

Can I just use a repeatable field and populate it with country names. Then when editing my project post type I can select from a country. And on the front end I can use the reapeatable field as a search filter for the map?

#2690572

Minesh
Supporter

Languages: English (English )

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

There will be couple of ways of doing this.

1)
- You can create a custom field that should hold the country name but this may have issues when user do mistake writing country name.

2)
- We can create a select field and auto-populate it's values using standard country name database table and then from the given address string you should try to fetch the country name. Later based on country name/code try to find the country ID from country table.

Please check the following ticket that might help you:
- https://toolset.com/forums/topic/upload-country-list-for-custom-field-of-type-select/#post-1376173
- https://toolset.com/forums/topic/setting-multiple-options-all-the-countries-in-the-world-for-a-select-field/
- https://toolset.com/forums/topic/custom-select-field-with-dynamic-data/#post-1427389
- https://toolset.com/forums/topic/country-and-city-drop-down/#post-1088365

3)
Better idea could be - you should Create a post type Country and import the Country posts to it using CSV.
- hidden link

Create a post relationship between post type projects and Country and connect the desired country with project.

#2690576

Can I just put the projects in post categories (countries) and filter by that?

#2690577

Minesh
Supporter

Languages: English (English )

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

Yes - you can also filter view by taxonomy so you can also add project to taxonomy Country.

#2690580

https://toolset.com/course-lesson/creating-a-custom-search/

This documentation was slightly confusing, took me forever to figure out how to add new custom search filters. The View Search box changes after you create your first view, the buttons to add new options appear further down the page in an odd area so the user interface is not intuitive but I finally got there. The instructions need to add more details about how the interface changes after your initial set up. Adding new things has a different look to it.

#2690655

Minesh
Supporter

Languages: English (English )

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

Thanks for your important feedback. I will share with concern person.

If your original issue is resolved with this ticket - you are welcome to create a new ticket with every new question you may have and you can mark resolve this ticket.