Home Aviation Embed an Australian METAR or TAF into Your Website with WordPress Shortcode...

Embed an Australian METAR or TAF into Your Website with WordPress Shortcode or PHP


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:

SPECI YSBK 191507Z AUTO 26004KT 9999 // OVC015 19/18 Q1012 RMK RF00.0/003.2

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 191108Z 1912/2018 19013KT 9999 -SHRA SCT010 BKN020 FM200000 15018KT 9999 -SHRA FEW015 BKN025 FM201000 14010KT 9999 -SHRA BKN020 INTER 1912/1914 5000 SHRA BKN010 RMK T 21 22 21 22 Q 1012 1011 1011 1012

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 191108Z 1912/2018
19013KT 9999 -SHRA SCT010 BKN020
FM200000 15018KT 9999 -SHRA FEW015 BKN025
FM201000 14010KT 9999 -SHRA BKN020
INTER 1912/1914 5000 SHRA BKN010
T 21 22 21 22 Q 1012 1011 1011 1012

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 1012, 19, and 18, a little bit of style can jazz it up a little.

YSBK Q1012 T19 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 19°C BNE 23°C MEL 12°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


The location refers to the Australian 4-letter ICAO code for requested airport. For example, Brisbane is 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".


The type defaults to TAF. To render a METAR report for Camden, use loc="yscn" type="metar".


By default we’ll remove line breaks and HTML from the returned data. To use a raw format and present the report as intended, use tidy="0".


The report is wrapped in paragraph tags (for WP) by default. To include a report inline without p tags, use p="0".


The cache refers to the amount of time in seconds that we’ll cache the report locally. Consideration should be made to the validity of reports when defining 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.


  • 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.

Embed an Australian METAR or TAF into Your Website with WordPress Shortcode or PHP

  • 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 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 °C.


Plugin Title: Metar Author: beliefmedia
Description: Metar is a plugin that includes global (and all Australian) aviation METAR or TAF reports, or…
Download (downloaded 2,438 times) | Plugin Page

Title: Australian METAR/TAF Reports
Description: Embed an Australian METAR or TAF into Your Website with WordPress Shortcode or PHP.
Download: Shortcode (V0.2) | PHP Code (V0.2) | Plugin Page

Shortt URL for this post: http://shor.tt/1XO9


Please enter your comment!
Please enter your name here