We've provided code to retrieve aviation airport METAR and TAF forecasts in the past, but they've used the NOAA Government database so didn't include Australian (non-RPT) aerodromes. The shortcode on this page, however, will permit you to:
- Include an Australian TAF and/or METAR report in a WordPress post or page.
- Include all Australian METAR and TAF reports for an entire area (ARFOR) in a WP post or page.
- Extract just the temperature, dewpoint temperature, or QNH, for a particular location, and display it.
What is a METAR and TAF? METAR and TAF reports are weather observations written in a global format standardised by the International Civil Aviation Organization (ICAO). Aircrew and operations departments usually make fuel and other operational determinations based on the actual observation (Metar) or the short-term forecase (TAF). The area forecast includes wind information, temperature, cloud, and other weather data that assists in route planning.
METAR WordPress Plugin
If you're using our Metar WordPress plugin, continue to use it. METAR will be updated very shortly to include other data... and it'll be entirely rewritten (it hasn't changed in years). The plugin is a sensible alternative to shortcode because of the ease in which it'll be updated.
The Result
To display the METAR for Bankstown (YSBK) we'll use the shortcode of [bom loc="ysbk" type="metar"]
. The result (in a blockquote for style purposes) is as follows:
METAR YSBK 222300Z AUTO 29005KT 9999 // NCD 13/05 Q1018 RMK RF00.0/000.0
To display the TAF for Sydney (YSSY) we'll use the shortcode of [bom loc="yssy" type="taf"]
. By default we'll remove line breaks and present the report inline. The result is as follows:
TAF YSSY 222004Z 2221/2400 30008KT CAVOK FM230000 24010KT CAVOK FM230300 20010KT CAVOK FM230600 12010KT 9999 FEW040 FM231100 29008KT 9999 FEW040 RMK T 12 18 21 20 Q 1017 1018 1016 1016 TAF3
Some prefer to display the TAF report raw with line breaks and formatting retained (as intended). To do so, use [bom loc="yssy" type="taf" tidy="0"]
. The result:
TAF YSSY 222004Z 2221/2400
30008KT CAVOK
FM230000 24010KT CAVOK
FM230300 20010KT CAVOK
FM230600 12010KT 9999 FEW040
FM231100 29008KT 9999 FEW040
RMK
T 12 18 21 20 Q 1017 1018 1016 1016
TAF3
We have the option of displaying limited meta data (basically, data within the data forecast string) in isolation. The function provides for the rendering of just the QNH, temperature, or dewpoint temperature.
To display the QNH (pressure) for a particular location, use [bom loc="ysbk" meta="q"]
; for temperature, use [bom loc="ysbk" meta="t"]
, and for dewpoint temperature use [bom loc="ysbk" meta="d"]
. While the default output will be just 1018, 13, and 05, a little bit of style can jazz it up a little.
YSBK Q1018 T13 DP05
On a couple of our sites (not necessarily aviation), we display the temperature for specific Australian locations. We cache data for up to a couple of hours to avoid unnecessary requests to the BOM.. The following data isn't valid - it's just designed to illustrate a point.
SYD 17°C BNE 19°C MEL 14°C
It's important to leave the meta
attribute empty by default, or when not required. When used it'll force a METAR to be returned rather than any other report that might be requested.
To request all (unformatted and raw) reports for a particular area, use [bom loc="21"]
(where 21 is Area 21). The example result is printed on this page.
WordPress Shortcode
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.
The first function randomly selects a user agent to emulate a broswer making the request. The function isn't intended to circumvent detection by the BOM (from what might be seen as abuse), but rather simply to emulate a browser request to ensure data is returned correctly.
The second function makes a request to the BOM server and, depending upon whether you would like a METAR/TAF or ARFOR, will return the appropriate array or result.
The next two functions take a METAR report and extract either the temperature, dew-point temperature, or QNH.
The last function is the working WordPress shortcode function. If you're using the function outside of WordPress, this is the only function you won't include (instead using the similar function below).
If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.
Shortcode Attributes
loc
loc="ybbn"
, Sydney is loc="yssy"
, and Temora is loc="ytem"
. To request the full Metar/TAF report summary for an area forecast, use loc="21"
.
type
type
defaults to TAF. To render a METAR report for Camden, use loc="yscn" type="metar"
.tidy
tidy="0"
.p
p
tags, use p="0"
.cache
PHP Function
Used outside of WordPress, the following may be used. All other functions above are required except for the shortcode function. Usage of Simple Cache is required.
Considerations
- Our METAR WP Plugin
will have the feature to pull out winds and other information so, once again, it's a safer and more feature-rich choice.
- The BOM has a copyright policy here
. Generally speaking, and not unlike the NOAA, Government departments are required to provide data on the condition that attribution is provided. The Bureau must be identified as the source of the material and a prominent link included to the BOM web page from which the material was sourced. Any copyright statement or logo included on, or in connection with, a set of material must be retained. All text or graphical re-presentation of forecasts must include the issue time and date and the validity of the period and must precisely reproduce any warnings associated with the material. It is up to the user to determine if usage of our code contravenes BOM policy or if a User Agreement is required.
- Upon entering the BOM aviation site, the organisation makes it clear that any operational information should be obtained from AirServices Australia
... and you should do the same. Attribution and standard disclaimers should apply. The reports rendered by virtue of the code on the page should be considered entertainment at best.
- When querying all reports in an Area, the returned text includes all airport titles in
h3
tags. You could alter this by using a simplestr_replace('h3', 'h4', $forecast);
or something similar if you wanted to alter the way it presents. A regular expression might be used to remove them completely. - To display the degrees symbol and Celsius sign (°C), use the HTML entity of
°C
.
Download
Title: Australian METAR/TAF Reports (WP Shortcode)
Description: Embed an Australian METAR or TAF into Your Website with WordPress Shortcode or PHP.
Download • Version 0.2, 2.0K, zip, Category: WordPress Shortcodes
PHP Code & Snippets, (2.1K)