WordPress Weather Widget

Number 5 in Widget-A-Day is a Weather widget.

It isn’t too fanciful. It displays the current condition, temperature, and the feels like temperature. It uses weather.com’s xoap api to retrieve the information. I’ll probably come back to this and make it better.

Download weather.zip

SVN Checkout
svn co http://svn.wp-plugins.org/weather-widget/trunk

Default display:
weather1cropped.png

Admin panel:
weather2cropped.png

Requirements

Installation

  1. Download weather.zip
  2. Extract and upload weather.php to the plugins/ directory
  3. Enable Weather Widget in the Plugin admin panel
  4. In widget admin panel, place Weather in the sidebar, and edit it to enter your location

Location

The location can either be a zip code for US users or the locid. To find the locid, you can do a search using http://xoap.weather.com/search/search?where=[search parameters].This will return an XML file with search results and their corresponding locid’s.

You can also find it out by the Weather.com website. After searching for and selecting you city, you will be sent to a url that will look something like, http://www.weather.com/outlook/driving/interstate/local/USTX0617?from=search_city, where USTX0617 is the locid.

Image Hosting

I’ve provided the images used and provided by weather.com here. If you want to host your own images, extract and upload the files, then, in the admin panel, edit the ‘Image Location’ field to point to your directory of images. Make sure to have the trailing slash.

If you don’t use your own images, you are free to use the ones that I’ve hosted, which are located at http://nothingoutoftheordinary.com/weatherimages/

Editting display

You can edit ‘Widget Formatting’ to change how the info is displayed. To access the variables, use this formatting:

  • %loc% - Location
  • %temp% - Current temperature
  • %feels% - Feels like temperature
  • %icon% - The icon referring to the current weather. This is just a number
  • %iconhref% - The location of the image with your set image location at the front
  • %attribution% - The link supposedly required to be displayed. Weather data provided by weather.com®

The default formatting is:

<img src="%iconhref%" alt="%cond%" style="float:right;" />
%loc%<br />
<span style="font-size: 150%;">%temp% °F</span>
(%feels% °F)<br />
<span style="font-size: 65%; float: right;">%attribution%</a>

Download weather.zip


27 Comments to “WordPress Weather Widget”

  1.  Weblogger.ch » Blog Archive » links for 2007-06-12 | June 12, 2007 @ 3:28 am

    […] Nothing to see here… » WordPress Weather Widget (tags: wordpress weather plugin) […]

  2.  Chris | August 3, 2007 @ 1:45 pm

    I assume that changing the “F” in the ‘Widget Format’ to a ‘C’ would display the weather in Celsius, but modifying this and saving didn’t change the display. Is my assumption wrong?

  3.  ah_skeet | August 3, 2007 @ 2:26 pm

    Yeah, that doesn’t change it. But I just hacked together a version that will allow you to change between Fahrenheit and Celsius.

    Updated version:
    weather.zip (gz)

    You have to select Celsius from the drop-down box, and change the ‘F’ to ‘C’ in Widget Formatting to make it look correct.

  4.  Chris | August 3, 2007 @ 2:38 pm

    Great! All the customization works now. I wanted to replace the location title and that works now too. Thanks!

  5.  jameswillisisthebest | September 8, 2007 @ 3:50 pm

    This is my first post
    just saying HI

  6.  Andre | October 23, 2007 @ 1:58 pm

    Just wondering if this works for Wordpress MU as well. Just checking…

  7.  Frank Lucas | January 7, 2008 @ 7:59 pm

    Any chance of inserting this as a function like ? I can use widgets but …

  8.  James | January 7, 2008 @ 9:45 pm

    Didn’t test this at all, but it should work. If it doesn’t, tell me the error and I’ll fix it. It doesn’t cache anything, but you should be using something like wp-cache anyways.

    Copy weather.php to plugins/ and enable, then in your theme file call weather(’location’).

    You can change the partner id, license key, and image location by subsequent arguments.

    Download weather-function.zip

  9.  Ed | March 26, 2008 @ 10:22 am

    Hey,

    I downloaded weather-function.zip. Does this allow me to put the code somewhere other than the sidebar? I have a list of locations across the US (a standard PHP, non-Wordpress page) and would like to show the weather for each location, if possible.

    Thanks ..

  10.  James | March 26, 2008 @ 12:39 pm

    Yes, but redownload it. I don’t know what I was doing when I first made it, but I just screwed it up completely. I just went through it and fixed it.

    For a non-wordpress page, just include weather.php, then call the weather function.

    I just did:

    <?php
    include 'weather.php';
    echo weather('77450');
    ?>
  11.  jeff | April 4, 2008 @ 9:54 am

    Hey.. question on your weather widget. Works great, but it’s the only widget that doesn’t have any space below it. If I put another widget right below it, it will literally sit right on top of the next text title. How can I add a little space to the bottom of the widget? Thx!

  12.  James | April 4, 2008 @ 12:19 pm

    In the widget formatting section, try adding a <br /> to the end.

  13.  stylus blog » Blog Archive » WordPress Weather Widget | April 18, 2008 @ 7:02 am

    […] usual, it is a simple process of downloading the files from the site, and then uploading them into your plugins folder on your server. You then need to look-up the […]

  14.  Mike | April 19, 2008 @ 1:58 pm

    I tried to get this to work for my blog in Iraq, but when I enable the widget I basically blank out my sidebar. I’m sure this is user error, but I’m not sure where to start. I put in the location (IZXX0008) and used your hosted icons, and made no other changes. Do I need to fill in the other boxes (license, etc.)?
    Thanks!

  15.  James | April 22, 2008 @ 4:25 pm

    Yes, partner id and license key need to be filled in. It should be done automatically, but it seems sometimes that doesn’t work.

    You can use these:

    Partner ID: 1036672568
    License Key: 561e1a02298548de

  16.  Shimshon | April 23, 2008 @ 7:17 am

    Hi,

    I have installed the weather widget, but it doesn’t really work. I don’t know what I am doing wrong.
    You can see it with 0 temp under the categories widget at http://www.shimshon9.com.

    Thanks!

  17.  MasterBip | April 30, 2008 @ 9:05 am

    Os there a way to show not only the current weather, but, as example, 4 days forecast?

    It would be great to have various days in the plugin!

    Thanks!
    CONDORES DE LA RUTA - MC

  18.  MasterBip | April 30, 2008 @ 9:07 am

    I just add this comment to be notifyed … Thanks for the WP plugin!

  19.  Michael Visser | May 4, 2008 @ 9:07 pm

    This is a really great plugin.

    I’m hoping to use it in a modified environment, instead of in the sidebar as an on-page element. Can you add support for template function calls like other plugins support?

    This would make this plugin even more versatile! Please let me know, thanks! :)

  20.  Mike | May 6, 2008 @ 1:06 pm

    I just came back to this after upgrading WordPress to 2.5, and now I can’t get to the admin panel. Either a bug or a boneheaded user error. Both equally possible, I suppose. ;-)

  21.  Nick | May 14, 2008 @ 10:37 am

    All of a sudden my weather values are not being shown, do you have any clue as to why this is happening?

    I haven’t changed anything lately, i tried upgrading to the newer version of wordpress but this resulted in no change.

  22.  Rakesh | May 23, 2008 @ 10:25 am

    I have using this widget for some time now, but it has stopped working now. All I can see is “°C ( °C)”.
    Do you know how we can fix this

  23.  joel | May 28, 2008 @ 7:38 pm

    I’m having the same issue. It stopped working sometime in the last few weeks. Anyone know why?

  24.  Ian | June 4, 2008 @ 5:12 am

    Egads, wish I’d read to the bottom before installing! Like the concept, would be good to know if it’s going to be fixed or not.

  25.  titi | June 14, 2008 @ 4:22 pm

    Still doesn’t work… :( WP 2.5.1

  26.  Satya | August 14, 2008 @ 3:47 am

    Recently i installed this great plugin for a travel blog of my client and it works without error in Wordpress version 2.6

    Thanx much for the plugin/widget.

  27.  shane | August 16, 2008 @ 3:02 pm

    I have a non-wordpress theme and I can’t get it to work.

    I tried to include the php file like in the post earlier but just get an error. Any ideas?

Leave a Reply


Close
E-mail It