1

The problem: I want to create a search form that allows users to select posts based on Prefecture and District (within that prefecture) in Japan.

I made "prefecture" and "district" are separate custom fields created using ACF. In theory, this shouldn't be a problem, but the issue is that while there are 47 prefectures there are over 1700 districts which would result in an incredibly long-drop down menu in the post admin.

To avoid this, I would like to create a separate field group for each prefecture. So, using US states and cities as an analogy, I would have...

  1. Los Angeles, San Francisco, San Diego, etc.
  2. Houston, Dallas, Austin, etc.

... depending on whether the post was for (1) California or (2) Texas.

However, ACF does not allow the same field name to be used twice and if I change the field name to "california_cities" and "texas_cities" then the search function would not be able to search both (I'm using the Search & Field plugin so I cannot create a custom query using WP_Query).

Question: Is there a way I can merge the (values in the) fields "california_cities" and "texas_cities" into a new field (say, "cities") in functions.php which gets registered so that I can select it in the Search & Filter options?

I would have thought that this is a fairly common issue (e.g. country-wide real estate searches), but cannot seem to find any posts that help me with the issue.

Thank you in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.