postnuke to wordpress converter/importer

So, I just recently switched my website from postnuke over to WordPress. As part of the process, I wrote a simple PHP script to convert all of the entries from the postnuke site over to WordPress. Although postnuke is a pretty heavy-duty CMS, there might be a few people out there who will make the same switch, so I decided to clean up the script a little and post it on the site for anyone who needs it. You can get it here. I put it under the GPL, so you can probably use it with no worries. If you do use it, send me an email or post a comment or something. I should add that it would be generous to say that I’m a novice at PHP. I’m sure there’s plenty I did wrong writing the script, but it works (for me), and that was enough.

Update 12 August 2005: I should have mentioned that this script was written for WordPress 1.2, and will require some massaging to work with 1.5. Check the comments for more info.

20 thoughts on “postnuke to wordpress converter/importer”

  1. I really need this script but it doesn’t do anything. I try to run it under my OS X iBook MySQL server but nothing happens. Any ideas?

  2. Well… it’s a PHP script, not an SQL script, so you should be running it on your webserver. Also, it doesn’t work “out of the box.” You have to change the table names where they are indicated in the comments to the ones that you use.

  3. No matter what I do I keep getting this when I try to convert:

    INSERT INTO `wp_categories` ( `cat_ID`, `cat_name`, `category_nicename`, `category_description` ) VALUES ( ‘2’, ‘Linux’, ‘Linux’, ” );Fatal error: Duplicate entry ‘2’ for key 1

    Any ideas?

  4. figured my last comment out, but now when I convert – categories go over nicely but the stories seem stuck. I get this repeating message:

    Just inserted ID 1

  5. I think it might be that your ID column for stories is not autoincrement? ‘autoincrement’ means that whenever a new record is created, it increases the number by one and uses that for the column value. If it doesn’t do this, the script is going to try to insert a new row that has a primary key that’s identical to another, which is an SQL no-no.

  6. Hi there.

    What version of postnuke and wordpress is this written for ?

    I’m converting a postnuke .750 to a WP 1.5 I’m having trouble with the script it seems to fail to insert the story data but has success inserting the category data.

    Thanks in advanced.


  7. Yes… this converter was written for WP 1.2, so I’m afraid with the new wordpress version it probably won’t work “out-of-the-box” anymore. still, it shouldn’t be too hard to take a look at the new WP table structure and update it.

  8. Bryan-
    I took the liberty of changing the code “just a bit” I removed these four vars for a quick fix. I hope this helps the other pn converts 🙂


    125 `post_lat` ,
    126 `post_lon` ,

    —- and this —–

    148 NULL ,
    149 NULL ,

  9. Hi,

    Thank you so much for the script – it is exactly what I was looking for. I ran it with limited success. It seems that it did not import the entire stories, only the lead-ins. I am also going from pn .75 to wp 1.5, and made the adjustment in comment 10.

    Take a look. The original pn site is at:, and the wp site at

    I’m a relative newbie, so I’m not sure what kind of adjustments to make to import the enitre story parts. Assistance greatly appreciated.


  10. Still working with it…now its really screwed up. Would you be able to give some hints as to how this thing is supposed to work…I mean, what is going where, and what is supposed to match up with whatelse?

    Thanks a million.

  11. Hi Michael…

    When I wrote this script, my goal was basically to grab the stories out of the pn tables and insert them with all the fields that WP wanted. I don’t know much about postnuke, wordpress, or php, so chances are that I didn’t do things the best way possible.

    The first thing to do is look at your pn tables using a mySQL administration program (phpMyAdmin is my favorite). Figure out what columns you want moved into WordPress, and for each record in postnuke, copy those columns into the corresponding WordPress columns. Where WordPress has columns that don’t exist in pn, you’ll have to insert default or null values. My script is just a simple implementation of this procedure.

    Unfortunately, I haven’t touched pn since last July, so I don’t know what might have changed in its table structure since this script was written. I did look at your site, and it seems like whatever column in postnuke stores the body of your stories is not getting copied correctly to the “yourblogprefix_posts” table “post_content” column.

    You could add some debug output to the script I posted to make sure the post content is being read correctly. Something like:

    printf(“Just read post content %sn”, $myhometext);

    right after

    $myhometext = mysql_escape_string($myrow[‘pn_hometext’]);

    Good luck!

  12. THANKS A LOT! You have no idea how much time you saved me. All I did was take the script and deleted the 4 lines like jk said and it worked beautifully the first time!

  13. Hi George,

    I’m sorry, but I wrote this script almost 5 years ago, and wordpress (and postnuke) are a lot more complex than they used to be. I doubt I’ll be able to update it.

Leave a Reply

Your email address will not be published. Required fields are marked *