Patch to Google sitemap generation

Recently we noticed we were getting errors from one of the WordPress plugins we use – the excellent Google Sitemap Generator by Arne Brachhold (v3.0b4).

If you have created static pages with a Parent Page, then your Google Sitemap will not have the correct address for these pages. And Google Webmaster will report errors.
Google Sitemaps Error Message

Update: this error only applies in 3.0b4 (the beta) – thanks to Pathos for reporting over at Pearsonified that v2.71 (the stable version) works correctly for child pages.

If you aren’t aware of WordPress Parent Pages or don’t care about sitemaps, don’t worry about this patch. Go and enjoy life :)

Still here? In brief, WordPress enables you to create static pages to go with your blog – we use this feature extensively on our client sites. Static pages can be created with a Parent Page – just check the right hand side of your WordPress screen from the Write Page or Manage Pages screen. Great for driving menus (so child pages appear on the menu of a parent page). You can see examples of this in action using the default Kubrick theme, or by looking at one of our client sites, Paul & Jenny Geelen, Ocularists.

Patch. We’ve patched the plugin for our use. Hopefully Arne will integrate Parent/Child support in one of his future releases. If you want to, you are welcome to look at our patched copy of Google Sitemap Generator 3.0b4.. Please note it is provided as is, is not supported, and if you choose to use you should know what you are doing. The extension has been changed from .php to .txt – to use it, you need to copy it to your plugins area and change the extension back to .php The change we have made involves replacing Arne’s main SQL select statement with a new statement. It works well on WP 2.0.5.

Preferences. To keep the patch simple, we’ve hard coded three preferences – inclusion of static pages, and exclusion of passsword protected and future posts. PHP coders can restore the preference behaviours at their leisure.

Performance. The patch uses a SQL union statement to manage the parent/child relationships – there are other ways to do it, for sure. If you’re a hard core MySQL guru and want to question the performance of this type of union query for very large WP installs …. well, this union approach is very efficient in Oracle, so since it tests very well on ‘normal’ sites (ie. ours) I think its fine to assume it will scale in MySQL also. But if you know the MySQL optimizer well and have some input, I’m interested. I learnt this approach from a true SQL master many (too many) years back. It never ceased to amaze me how the approach managed to:

  1. perform exceptionally well on truly massive data sets;
  2. attract criticism from supposed SQL experts who figured it looked so complex it would never scale.

Eventually the experts gave in (in the face of hard evidence), and just accepted that it worked brilliantly, though they didn’t fully understand how.

A final point – I have to say that Arne’s plugin is very well done, and this is a pretty obscure error. The community of developers creating and supporting WordPress plugins is awesome, and really help make WP the kick ass platform it is.