Documentation » Location and Weather

Location and Weather

IndieBlocks supports limited location and weather functionality. (Enable them at Settings > IndieBlocks > Miscellaneous.)

When enabled, a Location meta box is shown on post and note edit screens. In most cases, the page will ask for access to your browser’s Location Services and subsequently fill in a latitude and longitude. (If not, try ticking the “Update location data?” checkbox.

IndieBlocks also accept Micropub coordinates.

When a latitude and longitude are present and the post is subsequently saved, IndieBlocks will call Nominatim’s reverse geocoding API and (hopefully) save a town and country code in the geo_address custom field (and shown as the Location’s “name”).

IndieBlocks won’t fetch, e.g., venue names. But, if the Location name field is filled out by hand, that value will be saved (instead of the town and country mentioned above).

(Latitude and longitude, when present, are saved as geo_latitude and geo_longitude.)

If coordinates are present, current weather info will be fetched from OpenWeather’s API. For this to work, an API key should be set in wp-config.php:

define( 'OPEN_WEATHER_MAP_API_KEY', 'your-secret-key' );

Luckily, signing up is easy. Their free tier will do just fine.

Weather information is stored as a serialized array in the _indieblocks_weather post meta. The array contains temperature (always stored in Kelvin), humidity, and description (in English) values.

These (a location name and limited weather information) can be made visible on the front end by use of the Location block. Actual coordinates remain hidden.

The Location block is best used in theme templates (although it can be used in post content, too).

More options to be added soon …