I built a WordPress plugin and shortcode that grabs weather forecast from the NWS’ new Forecast API. Using the shortcode I can place the forecast anywhere on a post, page, or in a widget. The short code take 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 for the look of the forecast. The plugin also manages it’s own cache, as to not hit NOAA’s API every time the forecast is requested. The cache duration is customization.
So here is the shortcode in action. It will grab NOAA’s 7 day forecast for my neighborhood (43.0237, -71.6023)
Partly cloudy, with a low around 1. Wind chill values as low as -4. Northwest wind 0 to 5 mph.
Saturday Jan 18th
Snow likely after 2pm. Mostly cloudy, with a high near 20. Southwest wind 0 to 5 mph. Chance of precipitation is 60%. New snow accumulation of around one inch possible.
Snow. Cloudy. Low around 17, with temperatures rising to around 25 overnight. East wind 0 to 5 mph. Chance of precipitation is 100%. New snow accumulation of 4 to 8 inches possible.
Sunday Jan 19th
A slight chance of snow showers before 10am. Partly sunny, with a high near 37. West wind 5 to 15 mph. New snow accumulation of less than one inch possible.
Partly cloudy, with a low around 12. Northwest wind 5 to 10 mph.
M.L. King Jr. Day Jan 20th
Sunny, with a high near 23.
Mostly clear, with a low around 6.
Tuesday Jan 21st
Sunny, with a high near 20.
Mostly clear, with a low around 3.
Wednesday Jan 22nd
Sunny, with a high near 29.
Partly cloudy, with a low around 13.
Thursday Jan 23rd
Mostly sunny, with a high near 37.
Partly cloudy, with a low around 20.