So weather.com killed off the feeds for free on November 15, 2011. Strange thing…my feed is working now. I don’t know if it will work for new subscribers but it appears the old API keys do work! Cheers!

Latest version: 0.4.4
If your images are not displaying, go the the plugin settings page and select an image set. It should default to the original images, but if not, this is how you fix it. To make the plugin more easy to upgrade/install I’ve included two icon sets, weathercom (default) and Samurize. To download more, they can be obtained here: wp-weather-icons. Unzip them and upload to plugins/wp-weather/images.

Download link: http://wordpress.org/extend/plugins/wp-weather/

I have been using weather.com’s XML web service to display local weather information on my family website for several years. I decided to make the PHP code into a widget for wordpress. Here’s where you sign up for their service: http://www.weather.com/services/xmloap.html

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. Your location ID is a zip code for US and an alphanumeric code for international. Take Dublin for example – when searching for Dublin on weather.com you are taken to the following page: http://www.weather.com/weather/today/Dublin+Ireland+EIXX0014 and EIXX0014 is the location code.

Additionally, you may use a shortcode on any post or page.
If you want to show different cities on different pages/posts you can specify a location id:
[weather_display location_id="75034"]
If you’d like to display more days than default (what you set in the plugin options page):
[weather_display forecast_length=5]

I’ve also added support for a custom post field titled weather which takes a location code. Using the Weather Custom Field widget for your sidebar, you can have relevant weather information pertaining to the custom field location on any page or post.

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.


281 Responses

  1. 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.

  2. Not currently. I’m sure it is rather simple to do so, but how to display it might be a challenge.

  3. 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.

  4. 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.

  5. 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.


  6. 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.

  7. 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.


  8. 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…

  9. 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

  10. 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.

    <?php  if ( function_exists('weather_display'))  
    weather_display(); ?> 
  11. 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 204

    thats what happens when i try to display the plugin on my blog 🙁

  12. 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.

  13. 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.

  14. 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

  15. 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)

    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.


  16. welp, i’m an idiot.
    if anyone else is getting this problem, edit .htaccess and throw in
    PHP_FLAG output_buffering on

  17. 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?

  18. 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.

    CREATE TABLE hawaiibnb_com_2.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)
  19. 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?


  20. 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.



  21. 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.”


    Unfortunately I do not have a solution for PHP

  22. 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.

  23. 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?

  24. 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.

    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)
  25. 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 )
  26. 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.


  27. 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.


  28. 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

  29. 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?

  30. 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.


  31. 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


  32. 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.

  33. 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?

  34. 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):
    Source code: Weather plugin has:

    Local Weather

    The other sidebar calendar has:


    Thanks for the help.

  35. 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)

    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?

  36. 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.

  37. 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?

  38. 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!

  39. 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!

  40. Should you wish to modify the default cache age you will need to edit the plugin file. Line 218 should read:

    $interval = .5;	// Hours to keep data in db before being considered old

    Edit this interval to specify what portion of an hour to keep the data for.

  41. 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.

  42. 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.


  43. 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!

  44. 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.

  45. 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

  46. 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.

  47. 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

  48. 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?

  49. woops, sorry — didn’t see that you had responded — but yes, I’m using version 0.2.7, and its still not working.

  50. 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.

  51. 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.

  52. 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.

  53. 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

  54. 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.

  55. 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

  56. 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?

  57. 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.

  58. 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

  59. 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.

  60. 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.

  61. Wow Matt thats great, thanks for the update. I did notice that if you use inlinephp method, it displays where you place the code on the page, the new version [weather_display] pushes it to top of page. I have looked yet at the styles yet.

  62. I’ve signed up to weather.com’s XML service and have entered myu reg info into wp-weather, but the widget is displaying ,

    Currently: Ëš
    Feels Like: Ëš
    Hi: Ëš, Lo: Ëš

    rather than the actual info.
    All of the reg info is in correctly.
    Any suggestion?

  63. I get this too often and it prevents the posts from loading, so unfortunately I am giving up this plug until I see an update roll out. :parse(): expat: not well-formed (invalid token) [4/4/1]

    Fatal error: Call to a member function on a non-object in /home/upfishin/public_html/wp-content/plugins/wp-weather/wp-weather.php on line 392

  64. $fp = fopen($forecast_url,”r”); //do not check for success
    while (!feof ($fp)) //look for end of file, that may not exist
    $xml .= fgets($fp, 4096);
    fclose ($fp);

  65. Is there a way to make this plugin more dynamic in serving the weather… if I have several blog posts about several different locations, can I create a custom field called “Location” – where in the sidebar will check if the custom field is set, if so… display the weather for that location… I think that would be an awesome addition to this plugin.

  66. Great widget, Matt! I added in geolocation to the widget so it will display the weather of visitors to my website, not the city or location I choose. If you would like a copy of the code let me know.

  67. I am using your widget, installed, signed-up all fine. But it doesn’t really show the information my widget looks like this:


    Currently: Ëš
    Feels Like: Ëš
    Hi: Ëš, Lo: Ëš

    weather feed courtesy of weather.com – thanks!

    While I have inserted th city code: ITXX0067 for Rome in Italy.

    Please help?

  68. BJJ – I noticed this on my family blog last week some time. It appears that there must have been an incomplete XML response from weather.com that was saved into the database. For a quick stop-gap fix either go into phpMyAdmin and truncate the table wptableprefix_weather_xml or give it a wait of thirty minutes when the plugin should request fresh data from weather.com.

  69. hey mate, i´m using your widget, it´s working fine.. thanks for giving us this..
    i have a question, my site is in spanish and i could translate a few words like HI, LO, FEELS LIKE.. but is there anyway i can replace the date and eg.MOSTLY CLOUDY? or that part comes from weather.com…? Thanks in advanced..

  70. Hi,

    I have added wp-weather to my homepage but where do i find the ‘location id’ or the ‘city code’ for my city (Gothenburg, Sweden)?

    Thank you!

  71. This probably ranks as the most stupid question here, but is there a simple way to download this plugin as a complete package? I went to http://svn.wp-plugins.org/wp-weather/trunk/ but all I find is a list of files and folders, and the only apparent way to get them seems to be to download them individually and then recreate the folder structure again before uploading to my site.

  72. Just downloaded the plugin and installed and then registered at weather.com but did not receive an email with the keys from them. Is there anything I need to do to receive the keys?


  73. Great plugin ! Works perfectly.

    I was able to make a modifications to it to meet a need on my site – I have very limited coding knowledge – basic HTML, no php.

    Is there a way to add additional fields to the wp-weather manager page? I would like to be able to add text which needs to be updated weekly. Rather than go into the code each time to make the change, I was hoping there would be a way to add a field on the manager page for a date and a status.

    Any suggestions on how to do this would be greatly appreciated. My blog is beadsrock.com/blog where you can see your weather widget titled “Training Walks” and the first 2 lines which are the ones I would like to be able to update.

    Thank you very much for any help you can provide.

  74. Where may I see it working? Can visitors select their city weather (ie) by zip code or is it set permanently by admin?

  75. Matt,

    Is there a way to change the width of the output? I thought I could just update the width field on line 507 which reads:
    <input style=”width: 250px;” id=”weather-title” name=

    However, even when I changed 250px to something else…nothing happened. Any ideas?

    Thanks in advance.

  76. hi, everything was working fine, then all the sudden I get this error:

    WARNING isterxmlexpatnonvalid->parse(): expat: no element found [-1/0/1]

    Fatal error: Call to a member function on a non-object in /home/content/sitesite/html/site/wp-content/plugins/wp-weather/wp-weather.php on line 392

  77. Yes, I too am looking for how to include multiple cities. I haven’t found one single solution for any type of weather widget. Could anyone help us with this? Thanks in advance!

  78. Matt, I installed this plug in and it worked well till last week. Now I notice that the data is not refreshing unless we click on the “update options” button on the plugin page.

    Do you know why this might be happening? Should I try changing the refresh rate to .1 instead of .5 and see?

    Let me know how I can fix it.

  79. This widget crashes on me every once in a while and I can’t figure out why, it takes out all of my other widgets that are beneath it on the sidebar and my footbar – big long exception code. I can fix it immediately by going into the admin settings and just refreshing the settings – then it’s fine. Any idea why this happens?

  80. I love this plug in, its the most elegant solution for adding weather to a site. I want to add it to my template and want it to be Horizontal instead of vertical, any suggestions for updating the css it make that work?

    (If you view my site, im hoping to feature it across the very top of the page and fit it to the same width as my template.)

    Later ill change the graphics to match my theme.

  81. @skee/Trent: Today’s update will fix this issue for you.

    @Lincoln: You may have to dig into the code and change the html output. There are a few div’s/p’s in there that you may want to re-arrange.

  82. Now, after reading it may not be as simple as a css update to display horizontal, any suggestions will be appreciated. Looks like paragraph and line break tags are what puts this in line, not sure how i could make it sidways…

  83. Just wanted to second what Trent said. Around ever 4/5 loads/refresh my site will crash out and it replaces wp-weather with this:

    Warning: fsockopen() [function.fsockopen]: unable to connect to xoap.weather.com:80 (Connection timed out) in /home/SITENAME/public_html/wp-includes/class-snoopy.php on line 1142
    alert(‘Could not connect to lookup host.’)

    Any ideas?

  84. I can’t tell if that error means your host couldn’t look up the DNS entry for xoap.weather.com or the actual connection from your host to xoap.weather.com timed out. I’ll see if there is any way to work around this should it be encountered, but I don’t believe it is possible as the table for the old forecast data is emptied before the new forecast data is retrieved. Perhaps there is a way.

  85. I’ve installed this plugin on WP 2.7 and WP 2.8 and am not able to change the title of the widget – no matter what I put in the widget title area it always displays “The Weather” – any ideas of how I can get this to say something else?

  86. Kevin, I have not seen this issue before. I attempted to duplicate on a test install and am unable to. Do you have any additional information for this? Does it happen to any other widgets?

  87. I’ve tried it on 3 WP installs – one totally fresh – installing plugin right after wordpress. This is the only widget it happens to.

  88. There is a bug in your code. When you use $query = “INSERT INTO $table_name VALUES (‘$xml_url’, ‘$xml’, ‘$datetime’)”;
    $result = $wpdb->query($query) or die(‘Invalid query: ‘ . mysql_error());
    to insert the weather data into mysql, you should notice that there may be “‘” in the $xml(on example is Xi’an, which is the city I am now at), so you should replace all “‘” in $xml with “\'”.

  89. Hey Matt!

    Thanks!! The wp-weather is amazing.
    Can i make a question!? I hope so!!
    I’m using the wp-weather and I translate a few words. Just Hi, Lo, Feels Like… ok.. so, i wanna know if i can replace the date and the weather , translate monday, tuesday… cloudy…
    Thank you man!!
    Great job!!

  90. Hi Matt

    I added wp-weather and now have :

    Fatal error: Call to a member function on a non-object in /usr/www/users/theoar/wp/wp-content/plugins/wp-weather/wp-weather.php on line 394


  91. The config link to setup this widget does not work.

    I have the partner ID and the license key but no idea how to set this up now. I also know the City code.

    Please help or link to a config page for this widget.


  92. Hi Matt !
    Great plugin. Just what I was looking for
    But there is a small problem. I live outside the USA and some times weather.com doesnt display weather and so for my city it shows N/A

    However the plugin doesn’t display the N/A image which is bundled with the other plugin files (just like how it does for sunny and cloudy)
    So the widget just displays this:

    Currently: Ëš C
    Feels Like: Ëš C
    Hi: Ëš, Lo: Ëš

    It looks very odd on my sidebar..Any ideas ??

  93. Signing up to weather.com’s XML service is nothing short of ridiculous. Where are the codes for the service? They provide zero instruction as to what happens after they throw 10 or more + ads at you!

  94. Hi there,

    I just wanna know why sometimes show this message:

    Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in /public_html/site/wp-content/plugins/wp-weather/wp-weather.php:306 Stack trace: #0 /public_html/site/wp-content/plugins/wp-weather/wp-weather.php(306): SimpleXMLElement->__construct(”) #1 /public_html/site/wp-content/plugins/wp-weather/wp-weather.php(295): parseSimpleXml(”) #2

    Please, if you know.. mail me.
    Thanks again 🙂

  95. Hi,
    I’ve installed this plug-in but the weather only shows the information from when it is last refreshed.
    Is there a way to set this to automatically refresh whenever someone loads the page, or automatically in the background every 10 minutes or so?


  96. Laerte, I had the same issue, didn’t have time to invest though, I just switched off the plugin. Maybe the provided xml format has changed, I don’t know. If anybody has a clue…

  97. Steven – it is hardcoded in the plugin file to refresh every 30 minutes. This is required by weather.com.

    Pad/Laerte – the issue here is that sometimes weather.com doesn’t return the full XML in their response. I’ve coded around this in one instance, but looks like I need additional checks.

  98. Hi, sorry to be stupid, but I’ve signed up with weather.com and for the life of me I can’t figure out where to find the Id and license number. Can you help me?

  99. Thanks Matt, I did receive the email, but it says nothing about the key. I’ve found a number in what they sent me I think is the id – it says PID=XXXXXXXXXX, but nothing that says it’s a license key. How many digits is it and does it have a prefix.


  100. Oops, sorry Matt, must have been a glitch at weather.com, received yet another email tonight (two days after registering) with the license. Thanks for your help.

  101. I’m working on an inherited web site that uses this plugin, and it’s been working great, but we’ve now had a request to include wind information (we’re an outrigger paddling club and wind has a huge impact on our practices). Is there an easy way to add that bit of information? Otherwise, the plugin is great.


  102. Yes, the weather.com xml feed includes wind information. I’ll email you so we can figure out which section to edit as there are two different xml parsers in use to support both PHP4 and PHP5.

  103. New version out with fix for this and also added wind information in the settings as an option to display.

    Version 0.3.2 is the latest. Sorry for the rash of updates. Thought I’d caught everything in the code upgrade — it was a major overhaul.

  104. Before the update I was able to display the weather in a template using,


    but no longer.

    Is there a way to display the weather in a template without Widgets?

  105. Thanks for the info! Could you tell me where those 3 lines of code should go in the css template? Thank you very much Matt.

  106. matt, what am I doing wrong? The plugin is installed, obviously, with the Partner ID and License Key from weather.com. I’ve placed the widget on my sidebar and this is what the sidebar displays instead of the forecast:

    Warning: SimpleXMLElement::__construct() [simplexmlelement.–construct]: Entity: line 1: parser error : Start tag expected, ‘<' not found in /home/content/h/i/c/hickoryridge1/html/wordpress/wp-content/plugins/wp-weather/wp-weather.php on line 254

    Warning: SimpleXMLElement::__construct() [simplexmlelement.–construct]: HTTP/1.1 200 OK in /home/content/h/i/c/hickoryridge1/html/wordpress/wp-content/plugins/wp-weather/wp-weather.php on line 254

    Warning: SimpleXMLElement::__construct() [simplexmlelement.–construct]: ^ in /home/content/h/i/c/hickoryridge1/html/wordpress/wp-content/plugins/wp-weather/wp-weather.php on line 254

    Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML'

  107. Sounds as if the full xml didn’t come across the wire. You can empty the weatherxml table via phpmyadmin to force it to request fresh data – otherwise wait 30 minutes. Let me know.

  108. Matt,
    You were right, I just waited the 30 minutes. Looks really good – – now to css to customize. Thanks and nice work.

  109. Hi Matt –

    Thank you for the excellent work making this plugin, and maintaining it so that it works! Truly great.

    I’m wondering if there is any documentation on how to add / remove types of data (ie. high temp, low temp, etc..) in the widget?

  110. ps. I realize Hi and Lo are already on there, but I meant stuff like P.O.P. (it’s for a golf course, so probability of precipitation is important 🙂

  111. Matija – currently there isn’t any documentation on that. I could probably release a new version that includes the options to show the other items the xml contains. Let me see about that. The other items are humidity, barometer, chance of precipitation, dewpoint, UV and visibility.

  112. Matt – thanks for the very fast response.

    I just looked at the XML file, and it looks pretty straightforward. For example, adding:


    ..to the php file gives me precipitation as a number. I can format it myself. The only problem, of course, is if there are any updates to the plugin in the future (likely). Anyway, this is a good stopgap temporarily.

  113. I’ve signed up with weather.com but it has been 6 hours and I’ve not received a message from them with the key and ID numbers. Does this plugin still work with their feed or are they just very slow to respond? We’re expecting a big snow storm here tonight and I’d like to get this up on a community blog.

  114. Gerge – you are more than welcome to create a translation file to translate the phrases in the localization folder.

    Cynthia – the feed won’t function without the key and partner id. Not sure what the delay is…usually the information is sent out instantly.

  115. Hi,

    I use wp-weather, but I set only cities with ZIP like Frisco. I would like to set Pecs/pogany, Hungary but dosen’t work. Why?

  116. Added the plugin widget, it appears on my website, but no weather details. Where do I insert my country in order to make it appear?


  117. Hi Matt

    I ‘m wanting to use you plugin but in a different way to how it is currently designed, and wondered if you could tell me whether its possible.

    I have a blog that reviews walking locations, and therefore I don’t want to set a location as such. I want the location to be different for every post. Is it therefore possible to call the function with a different location setting…
    – show the weather for Somerset here http://tr.im/LRCY
    – show the weather for Sheffield here http://tr.im/LRD9

    Much appreciated

  118. Chris – that functionality isn’t available currently. However, it shouldn’t be too hard to add a location id parameter to the shortcode that will render the weather. Let me see about getting an update out.

  119. Thanks Matt

    I’ve already tried playing around a bit, removing the Location ID in the settings menu, and then trying to add it in the post directly using:
    [weather_display location_id=UKXX0446]

    Excuse my lame attempts… but it didn’t work 🙁

  120. Chris, I did some major modifications and got the shortcode now handling different locations in a post or page.

    Update your copy and try [weather_display location_id=”UKXX0446″] — note the quotes around the actual location id.


  121. Please tell me where I can download the two plugins. The Analytics folder is empty and I can’t find the Weather one. Thanks so much, Elena.

  122. Hey Matt! Great plugin/widget! Just one thing though! I’m wanting the 64×64 graphic to be placed to the right of the forecast and not below it. Is this possible? Could you tell me how to do this? Much appreciated!

  123. Until the last two recent upgrades to the plugin, everything worked fine.

    Now it starts showing the weather one day in the past.

    If I go to the settings page and click on ‘Save Changes’, without changing anything then the correct weather day is shown.

    My website is in the Pacific/ Auckland time zone and my server is Dreamhost in the US.

  124. Elena – I’ve added the download link to the top of this page.

    Craig – You’ll have to customize the output in the plugin file. If you’re on PHP5 then it will be around line 270, otherwise line 373.

    Rodger – I tracked down the bug. When a stale forecast is in the database, I was deleting the row but the code still used that old forecast data for display. Usually a refresh of the page would fix it, but that’s a bug so I’ll be releasing another update to take care of that. Thanks for the heads up!

  125. Thanks, Matt. I found the line of code of the small graphic, but how do I change the position of the graphic to the right of the forecast? Do I add properties inside the img tag? I’m not too familiar with PHP :-/

  126. Matt

    Since the last upgrade (3.6 I think), I’ve started getting errors. Annoyingly I copyed the error but I’ve since copied some other text 🙁

    From memory it said something like:
    Duplicate location UK0000044 Invalid XML

    To fix it, I went back into the plugin, and re-svaed the details, but this has to be done everytime I add a new post.

  127. Matt

    Got the error code as for some reason its just started showing again, without any updates or changes since I thought I’d fixed it:

    Invalid query: Duplicate entry ‘UKXX0446’ for key 1

    Depending which page I load, the UKXX0446 changes according to the location.

    I’ve had to disable the plugin for now so my site continues to work.

  128. Hi Matt

    Thanks for doing the lates update. As per the comment for Chris, I have the same rror message:
    Invalid query: Duplicate entry ‘NZXX0013’ for key 1

    When I go to the Settings page and click, ‘Save’ without updating anything, it then works OK.



  129. All, I think I have a fix worked out as I’ve identified an issue with a sql query. Once I receive word back from a tester, I’ll push out the update to wordpress.org. Hopefully this will be the last one for a while.

  130. Hi. I’m working on a WordPress site and I’l like to use your widget. I obtained the partner id and license key from Weather.com, but get this in place of where the widget should be…

    WARNING isterxmlexpatnonvalid->parse(): expat: no element found [-1/0/1]
    Incomplete forecast XML received.
    Please refresh your browser.

    Any thoughts on how to resolve this?

  131. Ali — this error means that there is no forecast data to display. Did a refresh of the browser work? Have you set the appropriate location code, license key and partner id in the settings?

  132. I installed wp-weather plugin, create an account on weather.com and got PartnerID and License Key. But I still see a message: “Incomplete forecast XML received.
    Please refresh your browser.” You know what I am doing wrong?

  133. Hi, again. Translation works fine now. But there are some Things that are not in translation file, like Wind information. 🙂
    Also is it possible to get Wind speed in km/h instead oh MPH?

  134. Hello,

    I am looking for a plugin able to save the weather in a mysql table each hour (for example). Is your plugin easily updatable do do that ?

    Thanks a lot.


  135. Hi, i found a little bug in this plugin. When switching betweeen Metric and standard units, it does not change MPH to km/h. The acctual data is changed but the name of the units are not.

    Also, it shoud be not “standard” but “imperial” i suppose.

  136. Hi,

    I’m getting this message frequently, not all the time. Any ideas on what maybe causing this?


    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 500001 bytes) in /home/fleafm/public_html/wp-includes/class-snoopy.php on line 894

  137. Is there anyway to add the weather in the WordPress Loop. I want it to be in the header file, not in a post or page. The short tags don’t work in the template files.



  138. alert(‘Could not connect to lookup host.’)

    This is the error I’m getting when using the widget. I have entered the Partner ID & License Key three times and no change. It is currently disabled on my website as it breaks the page.

  139. Any idea why I get two copies of the plug-in listed in the wordpress plugin admin page? One shows as activated and one not. Both are the same version ,and if I uninstall wp-weather both disappear. WP 3.0.4 with wp-weather 0.3.11

  140. Hello I updated to 0.4 (1,358 files – 11.5megs) today using WP Auto-upgrade and get errors. I’m running WordPress 3.05, Arras Theme

    I’ve deactivated, installed and re-installed and still get errors:

    Warning: closedir(): supplied argument is not a valid Directory resource in /home/site/public_html/wp-content/plugins/wp-weather/wp-weather.php on line 163

    Warning: sort() expects parameter 1 to be array, string given in /home/site/public_html/wp-content/plugins/wp-weather/wp-weather.php on line 164

    I de-installed and rolled back to .3.8 successfully (171 files 1.7megs)

    Probably just me or my config but I’ve been running the plug with no issues until this release.

  141. I’m getting the exact same error as the previous poster. How can I get beck to the previous version? Eek!

  142. Hey Matt,

    with 0.4 I get the same error:
    Warning: closedir(): supplied argument is not a valid Directory resource in …/wp-content/plugins/wp-weather/wp-weather.php on line 163

    Warning: sort() expects parameter 1 to be array, string given in …/wp-content/plugins/wp-weather/wp-weather.php on line 164

    Could you release a fix or shall we rollback?

    Kind regards,

  143. Hello! I am having a problem with the new update. When I try to set the weather to display 2 days, it shows 5 days. I have tried this on 4 different themes, it appears to be the WordPress 3.1 update that it is conflicting with.

    Thank you for your time, and great plugin btw!

  144. Excellent plugin, but the only thing missing is that when the weather is not available in any city to display a message and an image “not available at this time”, because for example in my city when there is no result I get tornado weather and could be cause for some misunderstanding.
    The rest is fine successes.

  145. Upgraded to 4.3 and using [weather_display] in page now shoots plugin output to top of page not matter where I have it on the wordrpress page. I’ve changed back to 3.8 which works as it should. Thanks.

  146. I recieved the following error activating the plugin:

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /hermes/web10/b2544/pow.rbickel/blog/wp-content/plugins/wp-weather/wp-weather.php on line 951

  147. Rodger – I’ve fixed the issue with 0.4.4

    Ryan – I can’t seem to duplicate the issue. Please let me know if the latest version fixes it…I’ve drastically reduced the file size in hopes of helping out users that use the automatic install/upgrade functionality.

  148. I did an automatice update and got the following when I tried to activate the plugin:
    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /hermes/web10/b2544/pow.rbickel/blog/wp-content/plugins/wp-weather/wp-weather.php on line 957

    I’m going to download the new version and try doing it manually.

  149. I deleted the auto update and uploaded manually. When I activated the plugin I got this fatal error:

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /hermes/web10/b2544/pow.rbickel/blog/wp-content/plugins/wp-weather/wp-weather.php on line 951

  150. Ignore the last comment. I accidently uploded .3. When I uploaded .4 I recieved the same error as when I did an automatic update “….line 957”

  151. I just upgraded to .4.4 and get this error on reactivation:

    Fatal error: Call to undefined function home_url() in /home/content/88/5919788/html/vip/wp-content/plugins/wp-weather/wp-weather.php on line 265

  152. Louis, I suspect you are on a wordpress version prior to 3.0 and thus I can not support any version below 3.0 as I strive to keep my code up to the latest standards and avoid deprecation. I have changed the required version in the readme for the next release.

  153. Hey, nice plugin. I am using on my wordpress website. I’d like to ask if there’s a possibility of adding translations.
    Thank you very much.

  154. Hello Matt,

    Thank you for this awesome plugin, it is really useful. I have 2 questions:

    How the translation works? I have created my own files wp-weather-es_ES.po/mo version and copied to wp-weather/localization (my wordpress is configurated in this language) but nothing happens all remain the same.

    The seccond question: Is that is there any way to call the function directly by php? I want to add it directly to the sidebar of my theme without using widgets. Just one more: Is there anyway to output only the icon and the currently temperature?

    Thank you for all your support

  155. @Matt, about the translation, after some experiments I have figured out how it works, I still have the other Question pending about the php direct call, and where to customize the output to only show the image/icon of the current conditions and the current temperature. I dont need any other info because I’m going to put it at the top of the page. I can put the thank you to weather tag under the icon.

    Thank you for your kind support

  156. Carlos, glad you got the localization working. You can call the weather function in php directly:

    <?php  weather_display(); ?>

    If you need to customize the output, this can be done. Depending on if your host is php5 or php4 the output is generated by two functions. PHP5: parseSimpleXml on line 300. PHP4: parseIsterXml on line 385.

  157. Ty Matt, I’m going to make a donation as soon as I get payed :). Just 1 thing the function that you are making reference in PHP5 parseSimpleXml is on line 599.

  158. It may vary depending on what version of the plugin you’re running. No worries – I don’t accept donations for this. I’m just glad people are able to make use of it! 😀

  159. Hello Matt,
    Thank you for this awesome plugin.
    I tried to translate your static contents to Japanese.
    But I could not translate all of the weather and the moon phase information that aggressively change from weather.com. (I translated a few words and success in my site. (Only Japanese display))
    Do you have all these information? if you have, I would like to translate it to Japanese.

  160. Hi Matt,

    Thanks for all your effort in the development and support of this plugin! Was wondering if you could help me.

    I’m trying to get your plugin up and running on a site I’m working on otesports.com.au – had everything working fine on MAMP and trasfered it over and I’m getting this error message:

    Fatal error: Cannot use object of type WP_Error as array in /home/otesport/public_html/wp-content/plugins/wp-weather/wp-weather.php on line 273

    I thought perhaps I couldn’t use the same ID and key on MAMP and the live site, but I got new versions and it’s still not working. Any ideas?

    Thanks for your time!

  161. Hiroaki – Unfortunately, weather.com does not provide all of the string values for conditions and this is rather frustrating as many people like yourself wish to translate that information. Sorry.

    Merlin – I don’t have any references to WP_Error in my code. I’m wondering if something is going on upstream. Is your issue still presenting itself?

  162. Hi Matt – I’ve been using your plugin on my site for many years and I must say that it has been great! I just moved from Delaware to Illinois and when I change Zip Codes or area codes in my local area I get an Invalid Query message. I’ve tried the following codes: 61856, 61821, USIL0209, and USIL0794. As soon as I change to other zip codes in areas I used to live it works fine. Can you see what may be causing these errors? Thanks for your help!

  163. This wordpress plugin is just great! I am wondering how I can use it with multiple locations (I need 4 main cities) on the same page.
    Thanks for your help.

  164. Hi Matt..

    How does one go about centering weather graphics and text within the widget? Everything gets pushed to the left side and looks wonky. Or, alternatively maybe there’s a way in which the graphics of sun/moon can be moved to the right hand side adjacent to the text for a more balanced feel?

    Love the widget otherwise!


  165. Please don’t let the plug-in die! I really like having the weather on my blog and will miss it. 🙁

    Thanks for a great plug-in and please consider making a new one now that weather.com is being greedy.

  166. Hello, is there some way of making this plugin work if I signup for the API?
    Is there somewhere in the plugin where I can replace a URL, or a key?

    Thanks for any help

  167. Why I can not show it on my site? after a period of connection problem with weather.com I decided to deactive this plugin, some recent days, I active it back but no date show on. Any advice? thanks.

Comments are closed.