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 Mar 21st
Mostly sunny, with a high near 52. West wind 10 to 15 mph, with gusts as high as 25 mph.

Tonight
Mostly cloudy, with a low around 33. Northwest wind 0 to 10 mph.

Wednesday Mar 22nd
Mostly sunny, with a high near 52. East wind 0 to 5 mph.

Wednesday Night
A chance of rain showers after 1am. Mostly cloudy, with a low around 35. Southeast wind 0 to 5 mph. Chance of precipitation is 30%.

Thursday Mar 23rd
A chance of rain showers before 11am, then rain. Cloudy, with a high near 54. South wind 0 to 10 mph, with gusts as high as 25 mph. Chance of precipitation is 80%.

Thursday Night
Rain likely before 11pm, then a chance of rain showers between 11pm and 4am. Mostly cloudy, with a low around 38. Chance of precipitation is 70%.

Friday Mar 24th
Mostly cloudy, with a high near 47.

Friday Night
A slight chance of snow showers after 2am. Mostly cloudy, with a low around 29.

Saturday Mar 25th
A slight chance of snow showers before 8am, then a chance of snow between 8am and noon, then a chance of rain and snow between noon and 2pm, then a chance of rain and snow between 2pm and 3pm, then rain and snow likely between 3pm and 5pm, then rain and snow likely. Mostly cloudy, with a high near 39. Chance of precipitation is 60%.

Saturday Night
Rain and snow likely before 8pm, then rain and snow likely. Mostly cloudy, with a low around 32. Chance of precipitation is 70%.

Sunday Mar 26th
A chance of snow before 9am, then a chance of rain and snow between 9am and 11am, then a chance of rain and snow between 11am and 4pm. Mostly cloudy, with a high near 41. Chance of precipitation is 50%.

Sunday Night
Partly cloudy, with a low around 31.

Monday Mar 27th
A chance of rain showers after 8am. Partly sunny, with a high near 48. Chance of precipitation is 30%.

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 *