Matt Gemmell

My new book CHANGER is out now!

An action-thriller novel — book 1 in the KESTREL series.

★★★★★ — Amazon

Convert Jerome's Keywords to WordPress Tags

development & source 1 min read

I finally got around to updating my WordPress installation here on mattgemmell.com to version 2.3, and I noticed the new native tags feature. I’d previously been using the excellent Jerome’s Keywords plugin for my tags, and I thought it would be fun to write a PHP script to convert Jerome’s Keywords tags into native WordPress 2.x tags.

You can download the script here. Note that it is not a WordPress plugin; you have to actually run the PHP script from the command-line, via something like this:

php -f jeromes_keywords_to_wordpress_tags.php

Make sure that you do the following things before running the script:

  1. Make a backup of your WordPress database, just in case. Seriously.
  2. Edit the 'Settings' part of the script to specify your database connection info. You can also choose whether or not the script reports its progress periodically (default is yes), and whether it deletes the old Jerome's Keywords data after converting it (default is no).

Now, a warning: I’ve run a few tests of the script on my local machine here, and I’ve also run it on this site’s database, and it worked just fine, but that doesn’t mean it won’t break for you. Have a backup of the relevant tables (they’re listed in the script’s comments, at the top), and don’t mess around with stuff you’re not going to be able to fix later.

Assuming everything works fine, you can run the script once and then throw it away. If you accidentally run it more than once, don’t worry - it won’t create any extra tags or screw things up. It should also work just fine if you’ve already manually converted some of your Jerome’s Keywords into tags, but not all of them. It tries to Do The Right Thing in those situations. :)

By the way, I’m releasing this code into the public domain. If you take it and improve it in some way, that’s cool - please release the improved version so others can use it too. Likewise, if you want to make a WordPress plugin version, go for it.

Update: I just found out that WordPress 2.3 and later natively supports importing Jerome’s Keywords tags! Well, consider this some sample PHP/MySQL code, then - and a reminder to check that a feature isn’t already there before implementing it yourself.