Watchdog Dempsey
Add to Google
Add to My Yahoo!
Add to My AOL

November 22, 2006

WordPress Sitemap Generator for Google News

category: General Chatter — David Stansbury @ 3:27 pm — permalink | pingback | RSS

Free download: Google News Sitemap Generator for WordPress

** This is not a WP plug-in, but is a stand-alone script for generating a sitemap RSS feed for Google News.

UPDATE March 10, 2008 - I fixed the invalid date format error bug.

Google announced their new Sitemaps for Google News program on November 21, 2006. I checked it out and the protocol is fairly standard and simple to follow. See the URL above for more information and technical specs.

I modified a simple, standard sitemap generator script (author URL dead) to output a Google News sitemap feed. All you need to do is download and unzip the file (below), open the php file with a standard text editor, modify the categories keywords list (click here for a list of available categories), and upload to your main WordPress directory.

You call up the script directly to generate the Google News sitemap file on-demand. For this site, the URL is http://www.kb3kai.com/david_stansbury/news-sitemap.php.

Once you have the program uploaded and running properly, you need to submit the feed URL to Google. Simply sign into (or sign up for) Google Webmaster Tools and, if your site is already considered a news source by Google, simply submit your feed URL as shown below:

Submit news site URL to Google

If your site is not in Google News you can request inclusion here.

Download the WordPress script here, verified to work in WordPress 2.0: Google News Sitemap Generator for WordPress

UPDATE March 19, 2008 - I used this script on a live Google-News-worthy website and submitted to Google Webmaster Tools as a Google News sitemap feed. They seem to have accepted it okay, see the screen shot below.

Google Webmaster Tools - accepted Google News URL submission

Have fun and happy publishing!

- Dave

Bookmark this to:
del.icio.us | soc.ialize.us | digg | furl | reddit | Yahoo | Google | Netscape | Live | AOL

• • •

23 Comments »

  1. I’m trying to use this plugin but it isn’t showing up in my “plugins” page; is there a bug?

    Comment by Dave — November 25, 2006 @ 4:21 pm
  2. Actually this is not a WP plugin, but rather a stand-alone addition. You simply copy the script to your default WP directory and call the script directory. For example, on this site you just call http://www.kb3kai.com/david_stansbury/news-sitemap.php and the script returns the RSS on-demand. Or, on your site it might be http://www.profectio.com/news-sitemap.php. If your site is considered a news source by Google (see the G press release about Webmaster Tools integration) you simply submit the URL to the script directly.

    Best Regards,
    Dave

    Comment by David Stansbury — November 25, 2006 @ 11:30 pm
  3. i have a question [sorry for my bad english] in my WordPress works the Google SiteMaps plugin - this new script works in a different RSS directory? i have problem when the two plugin works again? tnx

    Comment by enore savoia — November 28, 2006 @ 2:46 pm
  4. Greetings Enore,

    The Google News sitemap generator script is stand-alone, and works independently from WordPress functions and plugins. All you need to do is download the script, unzip it, open with notepad and customize the keywords list, save, then upload to your base WordPress folder. Then call the script directly to generate the sitemap XML on demand.

    If your site is currently indexed in Google News, you sign into Google Webmaster Tools and submit the URL to the sitemap generator. For example, on my site I would submit
    http://www.kb3kai.com/david_stansbury/news-sitemap.php

    Have fun and good posting!

    - David Stansbury

    Comment by David Stansbury — November 28, 2006 @ 10:13 pm
  5. tnx very much David … i have submitted the /news-sitemaps/ and works very good … now i must wait for verification of Google Webmaster Tools [pending status]

    take care and have your day
    Best Regards,
    Enore

    Comment by enore savoia — November 29, 2006 @ 12:41 am
  6. Hello David
    Many thanks for making this available, which I am sure will be a lifesaver.
    I am unable to test at the moment, but do you know whether this will work on WordPress Mu as well? As it is not a plugin as such, I imagine it will.
    Again, many thanks and best wishes.

    Comment by Atomboy — March 3, 2007 @ 4:45 pm
  7. Hey David,

    I love the plugin, but I am getting a strange error with my sitemap and I wanted to see if you’ve seen it before:

    Invalid date
    An invalid date was found. Please fix the date or formatting before resubmitting.

    Let me know what you think that may be…

    Comment by Neil — April 13, 2007 @ 10:24 pm
  8. Error:

    Invalid date
    An invalid date was found. Please fix the date or formatting before resubmitting.

    Comment by Giando — October 4, 2007 @ 5:08 am
  9. Same to me:

    Invalid date
    An invalid date was found. Please fix the date or formatting before resubmitting.

    I dont no why

    Comment by mario — November 1, 2007 @ 4:22 pm
  10. *** update ***

    I >> finally << fixed the invalid date format thing. I’m now looking at adding some keyword list intelligence, most likely pulling the WP category list if I can master the new WP 2.3 database changes. (rolls eyes)

    The download file (link at the top of the page) has been replaced with the corrected version.

    http://www.kb3kai.com/david_stansbury/wp-content/2006/11/news-sitemap.zip

    - Dave

    Comment by David Stansbury — March 10, 2008 @ 4:13 pm
  11. Hi Dave!

    This is absolutely awesome (if I get to use it). I actually chose drupal 6 in favor of wordpress.

    In your early posts I see you said it was not a WP plug-in, but standalone. Then there was a fix a couple weeks ago on 03/10/2008.

    Was the version prior to 3/10 a generic PHP file or was it still a PHP file with WP references, etc?

    I am trying to figure out how to modify for Drupal.

    Thanks Dave!

    Comment by james — March 27, 2008 @ 4:25 pm
  12. Great News but Google News give an error with your sitemap if you have a Site with more than 1000 urls. Is it possibile to modify this sitemap in order to have only your last 10 articles ? I say this because Google News check regularly when you publish something

    Comment by Matteo — April 4, 2008 @ 2:46 am
  13. Thank you for your script. I use it on my News Site now and i hope that google accept my request.

    Ilka

    Comment by Ilka — April 6, 2008 @ 5:40 pm
  14. Short of removing “disallow for .php” from robots.txt, how can I make this work with Google?

    Comment by Anonymous — April 9, 2008 @ 12:47 am
  15. Can you limit the Google News Sitemap to only include posts from one particular category of the blog? I am not very good in PHP, MySQL or wordpress coding. I am sure it probably can be modified oon line 43 (select all posts) but could use some help for WHERE category has a particular number. I will play around with it and try not to mess things up, but if you have a quick solution fort his it would be great!

    Thanks

    Comment by AKirk — May 5, 2008 @ 1:58 pm
  16. This script is just a little outdated, but I touched it up a bit to limit the sitemap to posts instead of pages, limited results to 1000, and also added tag support for keywords:

    Find:

    $rows = $wpdb->get_results(”SELECT ID, post_date_gmt FROM $wpdb->posts WHERE post_status=’publish’”);

    Change that to:

    $rows = $wpdb->get_results(”SELECT ID, post_date_gmt FROM $wpdb->posts WHERE post_status=’publish’ and post_type = ‘post’ order by post_date DESC limit 1000″);

    Find:

    echo “\t\n”;

    Change to:

    $tagger = ‘Base, keywords’; // change these keywords
    echo “\t\n”;

    Find:

    echo “\t\tU2,U2 tours,news\n”; // change these keywords

    Change to:

    $tags = get_the_tags($row->ID);

    if (!empty($tags)) {

    foreach($tags as $tag) {

    $tagger .= ‘,’ . $tag->name;

    }

    }

    echo “\t\t$tagger\n”;

    Comment by Jeff — May 28, 2008 @ 10:57 am
  17. Ok, well my mod did not translate well here, but you get the idea. Unfortunately it seems this version of wordpress on this site is munging the code in the comments.

    Comment by Jeff — May 28, 2008 @ 10:59 am
  18. First thanks for the beautiful piece of code.

    I have changed the code and now it comes out nice and clear. Two helps required.

    In the output I do not see the line breaks between links - how to add that and where…

    Also, tell me a way to limit the tag count as its picking up all the tags.

    Regards,

    Jack.

    Comment by Jack — May 30, 2008 @ 12:03 pm
  19. Today, I have emerged this error

    Comment by makeup — June 10, 2008 @ 3:22 am
  20. Hi David,
    This is wonderfully useful. We have two blogs just admitted to Google News. Google News only take articles created in the last 3 days. Anything older creates a zillion errors in Google Webmaster Tools. So I’m wondering if you can modify it to only generate the last 3 days, a change for which I would gladly make a donation.

    Comment by McCain — June 17, 2008 @ 6:47 pm
  21. Thank you for this plugin , wonderfull ;-)

    Comment by Fabio — June 27, 2008 @ 2:00 am
  22. Great script, works like a charm :) .

    @McCain: use

    AND post_date > SUBDATE(NOW(), 3)

    within the script, that should filter out to 3 days back.

    Comment by Slevi — July 13, 2008 @ 12:40 pm
  23. Hi David,

    I used your original concept and adapted the code slightly to produce a Wordpress plugin. Below is a link:

    http://wordpress.org/extend/plugins/google-news-sitemap-generator/

    This can now be installed like a normal Wordpress plugin and automatically updates when you save, publish and delete a post.

    I hope this will be useful for someone.

    Comment by Chris Jinks — August 4, 2008 @ 7:45 am

Comments RSSTrackBack URI

Leave a comment

Random thoughts from David Stansbury, KB3KAI