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.
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 242100Z AUTO 05005KT 9999 // NCD 25/18 Q1009 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 242003Z 2421/2600 02012KT CAVOK FM250200 04018KT CAVOK FM251200 36008KT CAVOK RMK T 24 27 29 29 Q 1009 1008 1007 1004 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 242003Z 2421/2600
FM250200 04018KT CAVOK
FM251200 36008KT CAVOK
T 24 27 29 29 Q 1009 1008 1007 1004
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 1009, 25, and 18, a little bit of style can jazz it up a little.
YSBK Q1009 T25 DP18
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 26°C BNE 22°C MEL 29°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.
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).
loc="ybbn", Sydney is
loc="yssy", and Temora is
loc="ytem". To request the full Metar/TAF report summary for an area forecast, use
typedefaults to TAF. To render a METAR report for Camden, use
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.
- 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
h3tags. You could alter this by using a simple
str_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