Usage

To retrieve a stored value use the following code:

  1. $city_selector = get_field('field_name');
If you use get_post_meta() to retrieve the value, you won't get the result as shown below, because the plugin applies some filters on the return.

The variable $city_selector returns 5 values in an array:

  1. array(5) {
  2.   ["countryCode"]=>
  3.   string(2) "NL"
  4.   ["stateCode"]=>
  5.   string(5) "NH"
  6.   ["cityName"]=>
  7.   string(9) "Amsterdam"
  8.   ["stateName"]=>
  9.   string(13) "Noord-Holland"
  10.   ["countryName"]=>
  11.   string(11) "Netherlands"
  12. }

Use it as follows:

  1. $city_selector = get_field('field_name');
  2. echo 'I live in ' . $city_selector['cityName'];
  3. echo 'which is in ' . city_selector['stateName'] . ' (' . city_selector['stateCode'] . ')'; 
  4. echo ' which lies in the country ' . $city_selector['country'] . ' (' . $city_selector['countryCode'] . ')';

This outputs:

"I live in Amsterdam which is in Noord-Holland (NH) which lies in the country Netherlands (NL)"