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

Tonight
A slight chance of showers and thunderstorms after 5am. Mostly cloudy, with a low around 62. Southeast wind around 0 mph. Chance of precipitation is 20%. New rainfall amounts less than a tenth of an inch possible.

Saturday Jun 22nd
A slight chance of showers and thunderstorms before 7am, then a chance of showers and thunderstorms between 7am and 8am, then a slight chance of showers and thunderstorms between 8am and noon, then a chance of showers and thunderstorms between noon and 1pm, then a chance of showers and thunderstorms. Cloudy, with a high near 75. Northeast wind 0 to 5 mph. Chance of precipitation is 50%. New rainfall amounts between a quarter and half of an inch possible.

Saturday Night
A chance of showers and thunderstorms before 11pm, then showers and thunderstorms likely between 11pm and 3am, then patchy fog and a chance of showers and thunderstorms between 3am and 5am, then patchy fog and a chance of showers and thunderstorms. Cloudy, with a low around 63. Northeast wind 0 to 5 mph. Chance of precipitation is 60%. New rainfall amounts between a quarter and half of an inch possible.

Sunday Jun 23rd
Patchy fog and a chance of showers and thunderstorms before 8am, then a chance of showers and thunderstorms between 8am and 11am, then a chance of showers and thunderstorms between 11am and 2pm, then showers and thunderstorms. Mostly cloudy, with a high near 81. South wind 5 to 10 mph. Chance of precipitation is 80%.

Sunday Night
Showers and thunderstorms before 10pm, then patchy fog and showers and thunderstorms likely between 10pm and 2am, then patchy fog and a chance of showers and thunderstorms between 2am and 5am, then patchy fog and a chance of showers and thunderstorms. Mostly cloudy, with a low around 65. Southwest wind 5 to 10 mph. Chance of precipitation is 80%.

Monday Jun 24th
Patchy fog and a chance of showers and thunderstorms. Partly sunny, with a high near 76. Chance of precipitation is 50%.

Monday Night
A chance of showers and thunderstorms before 2am. Mostly cloudy, with a low around 60. Chance of precipitation is 50%.

Tuesday Jun 25th
Sunny, with a high near 84.

Tuesday Night
Mostly clear, with a low around 62.

Wednesday Jun 26th
A slight chance of showers and thunderstorms after 2pm. Mostly sunny, with a high near 86.

Wednesday Night
A slight chance of showers and thunderstorms before 8pm, then a chance of showers and thunderstorms. Mostly cloudy, with a low around 65. Chance of precipitation is 50%.

Thursday Jun 27th
A chance of showers and thunderstorms before 2pm, then a slight chance of showers and thunderstorms. Partly sunny, with a high near 81. Chance of precipitation is 50%.

Thursday Night
A slight chance of showers and thunderstorms before 8pm. Mostly clear, with a low around 57.

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 *