Description
This filter allows you to change the pattern that’s used to filter out the location data from the Geocode API response.
This is necessary because the Geolocation API itself only returns a set of coordinates. To change this into a readable form, we need to send the coordinates to the Geocode API.
By default, it filters out the ‘postal_code’, ‘postal_code_prefix,postal_code’ value, but you can change this to the following values.
- street_number
- route
- political
- locality
- administrative_area_level_2
- administrative_area_level_1
- country
- postal_code
- formatted_address
You can see an example of the returned data from the Geocode API here.
If the postal_code field is not included in the response, then it will default to the format_address field. This will show the address in this format: Oudezijds Achterburgwal 1921, 1012 DX Amsterdam, Netherlands.
Usage
Changelog
Since 1.1.0 ( search widget only for now ).
Source File
This filter is located in /inc/class-widget.php
Placement
The code needs to be placed in the functions.php file inside your active theme folder.