'ACF Extended Pro Address field with optional sub-fields', 'fields' => array( 'address' => array( 'type' => 'String', 'description' => 'The full address', ), 'name' => array( 'type' => 'String', 'description' => 'Name of the location (e.g., street address)', ), 'city' => array( 'type' => 'String', 'description' => 'City name', ), 'state' => array( 'type' => 'String', 'description' => 'Full state or province name', ), 'stateShort' => array( 'type' => 'String', 'description' => 'State or province abbreviation', ), 'country' => array( 'type' => 'String', 'description' => 'Full country name', ), 'countryShort' => array( 'type' => 'String', 'description' => 'Country abbreviation (ISO code)', ), 'postalCode' => array( 'type' => 'String', 'description' => 'Postal code or ZIP code', ), 'placeId' => array( 'type' => 'String', 'description' => 'Google Places API place ID', ), 'lat' => array( 'type' => 'Float', 'description' => 'Latitude coordinate', ), 'lng' => array( 'type' => 'Float', 'description' => 'Longitude coordinate', ), ), ) ); } // Register the Address field type with WPGraphQL ACF add_action( 'wpgraphql/acf/registry_init', 'ccat_graphql_address_register_field_type' ); function ccat_graphql_address_register_field_type() { register_graphql_acf_field_type( 'acfe_address', array( 'graphql_type' => static function () { return 'Address'; }, 'resolve' => static function ( $root, $args, $context, $info, $field_type, $field_config ) { $value = get_field( $field_config['name'], $root, false ); if ( empty( $value ) || ! is_array( $value ) ) { return null; } $address_data = array(); foreach ( $value as $key => $field_value ) { if ( empty( $field_value ) ) { continue; } switch ( $key ) { case 'address': $address_data['address'] = $field_value; break; case 'name': $address_data['name'] = $field_value; break; case 'city': $address_data['city'] = $field_value; break; case 'state': $address_data['state'] = $field_value; break; case 'state_short': $address_data['stateShort'] = $field_value; break; case 'country': $address_data['country'] = $field_value; break; case 'country_short': $address_data['countryShort'] = $field_value; break; case 'post_code': $address_data['postalCode'] = $field_value; break; case 'place_id': $address_data['placeId'] = $field_value; break; case 'lat': $address_data['lat'] = floatval( $field_value ); break; case 'lng': $address_data['lng'] = floatval( $field_value ); break; } } return empty( $address_data ) ? null : $address_data; }, ) ); }