NOAA Weather Forecast – WordPress Plugin


Warning: file_get_contents(https://api.weather.gov/gridpoints/GYX/37,22/forecast): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in /home/customer/www/kimballrexford.com/public_html/wp-content/plugins/kmr-nws-wx/kmr-nws-wx.php on line 153

Warning: Invalid argument supplied for foreach() in /home/customer/www/kimballrexford.com/public_html/wp-content/plugins/kmr-nws-wx/kmr-nws-wx.php on line 170

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

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 *