Updated: 2008-0506
weather.com has made changes to their servers which now REQUIRE you to enter a partner id and license key in this plugin's settings. If you do not, they will not send the complete forecast data which in turn will break this plugin.
I have been using weather.com's XML web service to display local weather information on my family website for several years. Today I decided to make the PHP code into a widget for wordpress.
This widget uses a database table to cache the data for a half hour to avoid hammering the web service. Additionally, if you are using the wp-cache plugin, any changes to the options clear the cache.
To install: upload to your plugin directory, activate the plugin, set the options and add the widget to your sidebar.
This version now supports PHP4.
If you have questions, leave a comment or contact me.
Preview:

Downloads: 5837 times
Update: This plugin is now in the Subversion Repository.
http://svn.wp-plugins.org/wp-weather/trunk
Update: The plugin can be placed anywhere in your template with a simple call to the display function (assuming you have configured the basic options in the admin):
-
<?php
-
weather_display();
-
?>
83 Comments
Thanks for your plugin,I 've collected it on my blog here
http://www.tearsea.com/?p=632
Is there any possible work around to use this plugin if your server only has PHP4?
I will look into a way to parse the xml that will work under PHP4. Hopefully, there is an easy was to do so as SimpeXML really makes x-path navigation easy. Stay tuned for updates.
Is there a way to show more than one city location?
Not currently. I'm sure it is rather simple to do so, but how to display it might be a challenge.
Is there any way..to use this plugin without widgets?
Nice, i gonna try this! thanks!
i have a problem with this plug, i have the ID number and the licence key but not the other required fields... and when i update the options my blog "crash".
Check in this pls
http://img95.imageshack.us/img95/4548/clipboard01fl2.jpg
thanks
Looks like you're using this plugin on PHP4. I'm currently investigating a solution for PHP4 users, but at this moment, the plugin only works on PHP5 with SimpleXML.
I get the following error when I activate your WP Plugin:
---
Warning: require_once(/home/incog/public_html/blog/wp-admin/upgrade-functions.php) [function.require-once]: failed to open stream: No such file or directory in /home/incog/public_html/blog/wp-content/plugins/wp-weather/wp-weather.php on line 33
Fatal error: require_once() [function.require]: Failed opening required '/home/incog/public_html/blog/wp-admin/upgrade-functions.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/incog/public_html/blog/wp-content/plugins/wp-weather/wp-weather.php on line 33
---
I noticed that I do not have the file "upgrade-functions.php" in that folder and suspect this is the problem.
What is that file for, and why don't I have it?
I'm running WP 2.0.5.
Thanks in advance.
Rusty: That file is included in later versions of WP. I am utilizing it to create the database table that stores the weather data. The WP reference for the methods I am using is here. I suggest you upgrade to 2.1.2 as I can not support below 2.1 and there are many security fixes in the new code.
Cheers.
What code do I need to enter in my sidebar.php file to get this working? I installed the plugin and configured it without problems. But now I am stuck with how to get it up and running on my site. I have WP 2.1 installed along with PHP5. Any help would be appreciated.
Rhon - you need a widget compatible theme. Upon selecting a widget compatible theme from the presentation tab, you should see a new option on that page for Sidebar Widgets. This is where you drag and drop the wp-weather widget to your sidebar.
Cheers.
So their is no using this theme without having a widget compatible theme? I would really like to use the theme I hacked together and just be able to add some code to my sidebar.php file.
Any chance this can happen? Thanks...
What code do I use to get it to show on my site? I'm using WP
Ditto to what Rhon said. I hate widgets and there are still a whole lot of people who avoid them like the plague. Would be nice if this didn't require a "idget" ready theme. I'm sure there is a work around and just a matter of time before somebody posts it. If I were talented enough, I would.lol
I found a simple solution - if you'd like to include this, assuming you've already done the configuration part, insert this anywhere in your template.
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /srv/www/vhosts/sunsonic.de/subdomains/ardiem/httpdocs/1988er/wp-content/plugins/wp-weather/wp-weather.php on line 204thats what happens when i try to display the plugin on my blog
1988er -- you don't have php5 if you get that error. The next release of this plugin will check for it upon activation and not allow you to activate if the host is not compatible.
Hi,
Is there any possibility that the temperature will be shown in Celsius as well.
Thanks in advance,
Marc
Any chance the next version could have a 2-3 day forecast. It would be great if an effect like Yahoo.com has for their weather display could be used. I.E.: When you mouseover the current weather, it animated down to reveal the 3 day forecast.
Please add the option to view the forecast for the next few days.
Marc: it is actually very easy to add whatever you want to this and change to metric.
Just specify more in the $forecast_url
$forecast_url = 'http://xoap.weather.com/weather/local/' . $location_id . '?cc=*&dayf=' .$forecast_length .'&prod=xoap&par=' . $partner_id . '&key=' . $license_key . '&ut=C&ud=k&us=k&up=m&ur=m';I am also working on localizing this for Chinese right now, the xml is fairly straight forward for how to add things you want
Hey Matt, (or anyone who can help with this one)
I am getting annoying errors, which range from annoying to admin-panel destroying.
Here's my code for the translations, as you may notice, it is not complete yet due to a lack of a full list of what each graphic actually represents (that would be helpful)
http://www.notaclue.ktcs.net/dev/wp-weather.txt
The error I am getting is this:
Warning: Cannot modify header information - headers already sent by (output started at /PATH/public_html/wp-content/plugins/wp-weather/wp-weather.php:1) in /PATH/public_html/wp-includes/pluggable.php on line 329
I am stumped as I am not great with php and have been away from coding for a few years, any help is greatly appreciated.
Thanks
welp, i'm an idiot.
if anyone else is getting this problem, edit .htaccess and throw in
PHP_FLAG output_buffering on
I'm trying to get the weather widget working, and keep getting this error:
WordPress database error: [Table 'hawaiibnb_com_2.wp_weatherxml' doesn't exist]
Where can I find information on setting up this table in my database?
Sharon - your wordpress version might not have the required dbDelta function. If you can log into your phpmyadmin and execute this sql, you should be set.
Hi,
Do you have a time schedule for making this work for PHP Version 4.3.11? I have the same error on line 204 as 1988er.
As it isn't working on my server, is it worth the wait - does the service work for places outside the US?
Thanks,
Andy
Hi Matt,
Quick question on a problem I am experiencing. (WP 2.2, PHP 5.2.2, and an older hacked template that I have brought up to widget capable code (per the WP guys instructions and code). Here's the error I get:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@sundoggy.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
If you have any ideas, I'd appreciate it. It looks great, and I hope to try it out soon.
Thanks,
Paul
I understand. Thanks for the reply.
Unfortunately I received a similar reply from hostexcellence.com/ so it looks like I need to look for an alternative. Any ideas?
"I'm sorry, it is impossible to make an upgrade of PHP version on our servers at the moment. I regret.
We do not at this current time have any ETA for PHP5. We do appreciate your interest, and your patience in this situation. We will inform all current customers at such time as we do begin to offer PHP5."
Regards,
Andy
________________________________________
Unfortunately I do not have a solution for PHP
Thanks for this cool plugin!
I am having a problem with WP-Weather Manager. When I filled the partner id and license key along with zip code and then save the values and got an error stating:
WordPress database error: [Table 'campmark_wp_2.wp_weatherxml' doesn't exit]
TRUNCATE TABLE wp_weather xml
What does that mean? Your help is much appreciated. Thanks.
I have set up this plugin on one site, thanks very much for making it php4 compatible.
But I get the same error as Mitchell on another of my sites. I see that he has fixed the problem.
Any advice?
Andy, your wordpress version might not have the required dbDelta function. If you can log into your phpmyadmin and execute this sql, you should be set.
thanks again Matt. I got it working by adding the following SQL (excluding line 6).
CREATE TABLE wp_weatherxml(
xml_url varchar( 150 ) NOT NULL DEFAULT '',
xml_data text NOT NULL ,
last_updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
KEY xml_url( xml_url )
)
hi,
is there a way to display international locations. weather.com accepts city, country.
also is there a way to change the units say to metric.
daniel
Daniel,
I've updated this plugin to support metric units. Overwrite the old files with the version above and go to the options page for the plugin. Select metric for the units and save.
I do believe you can put any location code in the options page and have it display appropriately.
Cheers.
I'm trying to get this plugin working on a WPMU home page. I get the 500 server error when I try to put the tag in.. even as a widget on a widget theme i get the error..
any ideas?
runing MU 1.2.3 on dreamhost with php 5.2.2
I'm able to activate the plugin, but when i click the link to configure i get the following error:
Cannot load wp_weather/wp_weather.php.
what did i miss?
hi,
I'm using wordpress-mu-1.2.3-2.2.1 and when I tried your widget I get this error:
Fatal error: Call to a member function on a non-object in /homepages/36/d162900626/htdocs/blogs/wp-content/plugins/wp-weather.php on line 313
And line 313 code is this:
$day = $day_attributes['t'];
can you please look into it.
thx,
DesiTech
I haven't used WPMU for any testing. Which version of wp-weather are you using as my line numbers aren't matching yours.
I'm using Version: 0.2.1
Unfortunately I will have to decativate the plugin because I can't get it working without widget support - a shame.
when i use wp-weather (downloaded from your site) the following error appears
Local Weather
Warning: strtotime() [function.strtotime]: Called with an empty time parameter. in /home2/tonykawa/public_html/wp-content/plugins/wp-weather/wp-weather.php on line 177
TIA
I've added the widget and selected all the options, but it's just not showing up.
http://www.scwd.us
I was able to get this working. I could still see WP-Weather after moving my WordPress installation to a different directory, however, it wasn't actually installed. I removed and re-added it through the WordPress panel and it worked.
Is there a way to make the plugin grab a variable, so lets say depending on the category of the site, it displays the weather, e.g.
http://www.domainexample.com/category/new-york/
Show the New York weather.
Regards!
I was able to download and add the widget. however when I click on configure, the only option i get is Title: Local Weather. What am I missing?
hello:
I was able to install this on my first blog. Now I have added this in the second blog on the sidebar. It is showing up fine, however the sidebar for this theme has background for each set(archive, category, etc..) and this background does not get applied to this plug-in.Which file do i have to alter so i can apply class to this plugin too so that it blends with the rest of the other stuff on the sidebar. unfortunately my blog is internal and am not able to post the link here.
The theme link(Green Bug 1.1):
http://themes.wordpress.net/page/7/?cats0=25&sortby=date&order=DESC&andor=OR&submit=Show
Source code: Weather plugin has:
Local Weather
The other sidebar calendar has:
Calendar.....
Thanks for the help.
I've been getting the same "Table does not exist" error as Sharon (see comment dated May 28).
When I enter the SQL query into myPHPadmin as below:
CREATE TABLE flahute_com.wp_weatherxml (xml_url varchar(150) NOT NULL DEFAULT '',
xml_data text NOT NULL
last_updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
KEY xml_url (xml_url)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
I get the following error:
MySQL said:
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'last_updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',Any ideas? What am I missing?
Hey there....I'm trying to get the widget to jive with the CSS of my WordPress theme, but I nothing I do is changing the text color. Is there a trick to this? I have a theme with a black background and I can't get the text in the widget to be anything other than black.
I installed and activated the plugin. However, if I add it to the widget sidebar or edit the sidebar php file, an insane amount of errors appear down the page... how can I fix this?
Not sure what errors you're getting so can you put up a link?
I have the plugin widget running on my site, but can't seem to get the css right so that it looks like the other widgets in my sidebar. Can you guide me in the right direction. Nothing I do to the css seems to make any difference. Thanks!
thank you for all your hard work, people should understand you are doing this for free and not expect the world! in any event, i just want to fix this: "The data from weather.com is cached in the database for one half hour to avoid unnecessary calls to the web service." we live in a severe weather zone and 30 minutes can literally make the difference between life and death! thanks for your contribution!
Should you wish to modify the default cache age you will need to edit the plugin file. Line 218 should read:
Edit this interval to specify what portion of an hour to keep the data for.
Hi first off thanks allot for your hard work. Works great on allot of my Blogs. On my sites I changed the weather pictures maybe someone is interessted? Found them to be more appealing to my site. http://start.swiss420.ch In that sense how about a theme collection on your site of different Weather Pictures to fitt the different Webstyles? Also language translations would be interessting. Always have to go in and change everything around with each new version. Would it be possible to share the work on your site? No Problem if you dont have time. Allready happy with all the work you put in. Just giving some Feedback from little old Switzerland. Note to everyone with Problems. Try Firefox with Firebug it will help you solve many format etc. related Problems.
Good idea for a plugin and widget but why not link to The Weather Network for users that live outside the US?
Weather.com can accommodate international cities. Just find your appropriate city code.
What code would I need to insert to add this to a static page on my blog?
Great plug-in! Just a couple of suggestions:
1. You might want to use .gif files instead of .png for the weather icons. Due to an error in IE 6 (and, I think earlier versions), .png files don't display transparencies. I had to convert the files to .gifs (with photoshop) in order for them to display properly.
2. It would be great to have the ability to display two different cities.
Thanks!
Is there any way to place the three day forecasts side by side?
Alicia - out of the box this functionality is not supported. You can edit the file to remove the paragraph and line break tags.
Was working fine for months, then suddenly, overnight, I'm running into the same error that DesiTech refers to above...
Fatal error: Call to a member function on a non-object in .../wp-content/plugins/wp-weather.php on line 313
So I updated to the most recent version of your plugin but I'm still getting the problem, only now it points to line 366 as the culprit. Was this ever resolved? I don't understand why it would happen overnight like that. I've deactivated all the other plugins, but I'm still getting the error. Please help!
Stefan - can you confirm if your host is running php 4? The author of the class i use in php 4 instances has mentioned this error in his documentation but i can not reproduce in my own environment.
Same thing here as Stefan, all was fine yesterday and today I get the same error. Nothing has changed on the page.
Fatal error: Call to a member function on a non-object
weather.com changed their url parameter format this morning. Version 0.2.7 fixes this. Without this version of the plugin the forecast data will be missing from the weather.com xml feed. Please update to this version and report if it fixes your issue.
I updated and still get the error:
Fatal error: Call to a member function on a non-object in /wp-content/plugins/wp-weather/wp-weather.php on line 366
yes, currently php 4.3.11, host reports no recent changes on the server side, so still baffled as to why it should work fine for months, then suddenly stop working... could be a weather variable that hasn't occurred for the past several months?
woops, sorry -- didn't see that you had responded -- but yes, I'm using version 0.2.7, and its still not working.
I'm getting the same error as stefan. Worked monday, stopped tuesday. At first on version 0.2.6, then updated to 0.2.7...same line is calling the error "$days = $day_forecast->children();" on line 366.
Do you guys have a valid license key and partner id saved in the settings? I know previously they let you access the xml feed without one, but they clamped down on that Monday and require one now. Without these, you won't get the full xml data which will cause the call to ->children() to fail.
Thanks for the suggestion Matt, this was my problem.
I had a ID and key, but forgot how I got them, so signed up fresh and all is good now.
Except I have a stray bullet under the city name that I don't remember seeing before.
Same here, thanks Matt, its working now. Great plugin, by the way, works with Wordpress Mu allowing multiple city weather forecast from one install (where each sub-blog localized for a different city), out of the box, no tweaking required. Thanks again
Is there way of putting the weather into the body of a single page? I like it on the side pane but it takes up too much room so I wanted to create a weather page so I can have a long range forecast as it would have the space of the whole page.
Also, I tired putting in the short php code mentioned at the top of this page but it removed all the data from my side panel and put it in the bottom of the body of the page.
hi ,
i have one issue please help me to sort it out
i have installed wpmu in my server for each place in india i have created one blog ,now i want to display the weather report of each blog (i.e weather report of a place corresponding to that particular blog )
how to do this dynamic display of weather report in wpmu ?
Thanks in advance
Jay, I haven't set up an install of wpmu, so I'm not sure what to advise you. If you look at Stefan's post a few above your's his site is powered by wpmu and utilizes wp-weather. Perhaps he has a contact form and you can ping him about it?
Dave -- to accomplish this in a page use a plugin to execute PHP within posts/pages. i tested this one: http://wordpress.org/extend/plugins/inline-php/
and placed this code on a page:
My server recently upgraded to PHP 5.2.5 and disabled fopen functionality. As such, this plugin no longer works for me. Has anyone rewritten the Get XML Query Results section (starts on line 238) using cURL functons? If so, can you please post the code snippet? Thanks.
I am getting this error too.
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in .../blog/wp-content/plugins/wp-weather/wp-weather.php on line 237
PHP version = 5.2.6
Webserver = Apache
That error is definitely an issue that more people are going to run into - hosts tightening up their php configuration. I need to add in a method of retrieving the xml via curl but have not had the time yet. Stay posted and I'll try and add that soon. If anyone else wants to submit a patch that checks for fopen and on failure uses curl, feel free to send it my way and I will include it with kudos.
I recently developed a WP site locally on my machine running v 2.5 of WP. I just made the site live today using v 2.6 and when the plugin is activated I get this error:
Invalid query: Table 'db251978689.wp_weatherxml' doesn't exist.
Table db251978689 is the name of my hosts database. I uploaded the plugin, activated it, added in all the Weather.com information and added the "" to my sidebar and that's the error I get. I'm not sure if there is something I'm not doing right or what.
Thanks for the help.
3 Trackbacks
WP Plugin:wp-weather...
This plugin display local weather information on your blog
Table of Contents
Name(插件名称)
Author(插件作者)
Version(插件版本)
Download(下载插件)
Introduction(插件介绍)
Installation(安装插件)
Name....
[...] Visit [...]
[...] wp-weather widget uses Weather.com to show forecast information for a city. [...]