Support

Account

Home Forums General Issues Is my field/data structure correct? Reply To: Is my field/data structure correct?

  • Question one:

    That’s the easiest and fastest way to do it using fields. On the other hand, you could create a custom taxonomy that is hierarchical and then at the top level create the states and then on the second level you could have counties.

    To do it with fields so that only the counties you want are loaded would take a lot more work, you’d need to create some custom javascript to reload the county select field whenever the state field was changed. Possible, but takes longer and the result from the users perspective will be the same.

    Question 2:

    I would also carefully name my county fields. If you are using the state abbr for the value of state then:

    
    ia_county, nm_county, etc
    

    then you can simplify getting the county

    
      $county_field = $state.'_county';
      $county = get_field($county_field)