NOAA Weather Forecast – WordPress Plugin

I built a WordPress plugin for displaying the weather forecast. The forecast data is pulled from the NOAA NWS Forecast API. The plugin has a shortcode that can be placed on a post, page, or in a widget, anywhere you want to show the forecast.

The shortcode takes two perimeters:
1) the location (as latitude, longitude), and
2) the number of days to show. Something like this
[ weather location="43.0237,-71.6023" days="4" ]

The plug has a separate template file that can be customized to change the look of the forecast.

The plugin has built-in cache management. Caching prevents it from hit NOAA’s API every time the forecast is requested. If you hit the API too often NOAA may kick you off. The cache duration is configurable. A 6 hour cache works well for general use.

So here is the shortcode in action. It will grab NOAA’s 7 day forecast for my neighborhood (43.0237, -71.6023)

Goffstown, NH

This Afternoon Oct 18th
Sunny, with a high near 55. South wind around 0 mph.

Tonight
Clear, with a low around 31. South wind around 0 mph.

Monday Oct 19th
Sunny, with a high near 61. South wind around 0 mph.

Monday Night
Patchy fog between 9pm and 2am. Partly cloudy, with a low around 36. North wind 0 to 5 mph.

Tuesday Oct 20th
Mostly sunny, with a high near 63. North wind around 5 mph.

Tuesday Night
Mostly clear, with a low around 35.

Wednesday Oct 21st
Sunny, with a high near 58.

Wednesday Night
Partly cloudy, with a low around 33.

Thursday Oct 22nd
Mostly sunny, with a high near 62.

Thursday Night
Mostly clear, with a low around 37.

Friday Oct 23rd
Sunny, with a high near 54.

Friday Night
Mostly clear, with a low around 31.

Saturday Oct 24th
Sunny, with a high near 53.

Published by

Kimball

Kimball is a website designer and developer in Pembroke, NH.

One comment on:
“NOAA Weather Forecast – WordPress Plugin”

Leave a Reply

Your email address will not be published. Required fields are marked *