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

Overnight
Rain and snow. Cloudy, with a low around 30. South wind around 5 mph. Chance of precipitation is 80%. Little or no snow accumulation expected.

Friday Feb 23rd
Rain and snow. Cloudy, with a high near 44. Northwest wind around 5 mph. Chance of precipitation is 90%. Little or no snow accumulation expected.

Friday Night
A slight chance of rain showers before 7pm. Mostly cloudy. Low around 23, with temperatures rising to around 29 overnight. Northwest wind 0 to 10 mph. Chance of precipitation is 20%. New rainfall amounts less than a tenth of an inch possible.

Saturday Feb 24th
Mostly sunny, with a high near 28. Northwest wind 10 to 15 mph, with gusts as high as 30 mph.

Saturday Night
Mostly clear, with a low around 11. Northwest wind 5 to 15 mph, with gusts as high as 25 mph.

Sunday Feb 25th
Sunny, with a high near 38.

Sunday Night
A slight chance of snow showers after 1am. Mostly cloudy, with a low around 25.

Monday Feb 26th
A slight chance of snow showers before 7am. Partly sunny, with a high near 46.

Monday Night
Partly cloudy, with a low around 26.

Tuesday Feb 27th
Mostly cloudy, with a high near 49.

Tuesday Night
A chance of rain showers between 7pm and midnight, then a chance of rain. Cloudy, with a low around 40. Chance of precipitation is 50%.

Wednesday Feb 28th
Rain likely. Cloudy, with a high near 56. Chance of precipitation is 70%.

Wednesday Night
Rain likely. Mostly cloudy, with a low around 38. Chance of precipitation is 70%.

Published by

Kimball

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

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

Leave a Reply

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