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.


Comments

Kind of a question2004-09-30 16:39:35

Could I ask why? I am really curious?

bryan2004-09-30 17:32:12

you’re asking why i switched from postnuke to wordpress? or why i wrote the converter?

Mattz2005-01-06 05:06:53

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?

bryan2005-01-06 10:52:40

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.

Wolf2005-02-22 18:10:14

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?

Wolf2005-02-22 18:23:00

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

bryan2005-02-22 23:04:37

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.

jk2005-03-27 20:08:17

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.

J

bryan2005-03-28 09:25:51

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.

jk2005-03-28 11:38:17

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 :-)

Lines:

125 post_lat , 126 post_lon ,

—- and this —–

148 NULL , 149 NULL ,

Michael2005-07-06 10:47:22

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: www.bullnotbull.com/bull, and the wp site at www.bullnotbull.com/wp.

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.

Michael

Michael2005-07-06 12:03:54

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

bryan2005-07-06 13:29:42

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!

RC2005-09-15 15:06:32

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!

Anthony2006-02-23 00:58:46

Hey, I’ve got a WP 1.5/PHP 5 version of this working if anyone wants it.

Anthony2006-02-23 01:03:33

oh, forgot my email address. catch me at spartan.ii [at] mac [dot] com.

George2009-08-13 00:24:22

Oh man, how does it work on wp 2.8.4? I would just love your script for he site www.kohtao-community.com. It’ a charity site that urgently needs an update…. Can you help?

bryan2009-08-13 08:48:39

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.

George2009-08-13 19:10:17

Thanks for looking into it anyway.

bryan2009-08-14 15:00:58

George:

I actually just noticed this updated version of my script that someone made and that works on Wordpress 2.5, at least: http://www.thereitis.org/wp-content/uploads/2008/12/pnconvert_250.txt. Maybe that can help?

cell phone companies can suck it

I have a cell phone. It’s 4.5 years old. It works great. It makes phone calls. Woo-hoo. It’s the same phone number I’ve always had… which means it’s an Austin area code, though (as you may have figured out by now) I live in California. When we move to Fremont, I’ll be in the same area code as Berkeley, and Leslie tells me you can call all around the bay locally anyway, so I’ve been looking into getting a new phone/carrier.

It’s obnoxious to have to pay monthly for something–I despise bills on general principle. But it’s fair: they provide a service month-to-month, and I pay for it. But why on holy earth do I have to sign up for a year with one of these evil companies? And why do I have to buy a phone from them? And why can’t I take my phone with me when I leave one company and go to another? I’ll tell you why: because American cell phone companies are an evil cabal created to milk the people of This Great Nation of their money and their very souls.

I considered going with Virgin’s offering, where you buy a phone and pay by the minute with no contract or bill at all. This would be cool, and seems economical up to maybe 300min/mo. I’m not sure it would work out to be financially advantageous if I had no land line to back it up. Still, no contract and no bills seems awfully nice to me. You don’t even have to give them your name, you can buy the phone with cash and refill it with cash. Cypherpunkness, here I come.

On the whole though… how did we get suckered into the current state of things? Most places try to get you to sign 2-year contracts now. 2 years?!?! In europe, you buy a phone, get a little card, and pop the bad-boy in. Period. You want a new phone, buy it, pop the card in, and all your numbers and settings and everything are there. You can sell your phone. You can get pre-paid cards to go in your phone. You can borrow your friend’s phone for 5 minutes and pop in your card to make the call. Why can’t this sanity make it across the pond? Sigh.

One of the reasons American companies do the lock-in is because they heavily subsidize the cost of the phones. This is because, for some reason, it’s important for your cell phone to browse the internet and take pictures and send email and make coffee and all sorts of other worthless crap. Guess what? I pretty much want to just make phone calls! So you can go ahead and leave out the color screens and the singing songs and the flashing and dancing and spare me the stratospheric price point and all it entails. The geek inside me wants to be interested in fun little features, but the homunculus of reason knocking around my head balks at being cowed into a 2-year contract for some silly little plastic noisemaker that could enable me, theoretically, play tetris while surfing the web while bluetoothing around while driving my car at speeds fatal to any pedestrians who have the misfortune to get in my way. And the ability to do this (from what I’ve seen out on the road recently) is becoming more and more critical to a modern lifestyle. And I’m nothing if not modern.

Cell phone companies are just thing to bring out the Luddite in me.


Comments

Ali2004-07-19 11:44:29

You can buy unlocked phones in the US that you can take to any carrier that has a compatible network. The trouble is that these phones are easily 3x more than you would pay for them normally. One nice thing about T-Mobile is that they will give you the unlock code any of their phones if you are a subscriber. So you can use it on any service. Of course to get one of their phones for cheap/free you’ll have to sign a year contract but after that you could go anywhere you please.

Chris2005-09-17 23:53:38

I agree. I was thinking today of buying an old startac motorola. that was a good phone. it worked and was a good size. but i am sure that they would give me hell if i tried to hook it up. probably saying it wouldn’t work with our new service bla bla bla. cell phone companies suck period! I may just get a beeper. stupid razor rokr cellpone geeeks.

his and hers 20-inch opulence

A while ago, I got a Dell 2001FP 20-inch flat panel display. It’s gorgeous.

pic of dell 2001fp

Leslie has gotten a bit tired of her little 15 inch computer screen. So, I decided to get one of the fancy new screens from Apple, and give Les my old one. The new one looks like this:

apple 20

Mmm… Now we’ll both have spoiled ourselves with the excess of 20" flat-panel monitors. I’ve thought for a long time that there is no computer accessory more important than your monitor. No matter what you’re doing with your computer, or how fast it is, you always have to interact with it through the display. So I think it’s worth it to invest in a nice display. Before my current panel, I had a 19-inch Mitsubishi tube that served me for about 4 years. It’s life was actually cut short… I’m hoping to get as many as 10 years out of these panels (I’d better, anyway. In for some lean times ahead :)

This will displace Leslie’s wonderful little iMac. We were thinking we could put it downstairs in the new apartment so we can have a living room computer (because walking upstairs is far too much of a hassle). Any other ideas on how to keep the “kitten” in service?


Comments

cameron2004-07-13 20:23:45

i don’t understand why this replaces the kitten. what will the dell monitor be hooked up to?

bryan2004-07-13 21:16:03

Ah yes, I did side step that one. I pieced together an dual 800Mhz G4 Powermac from parts at work… Les also got a new computer in the deal :)

cameron2004-07-14 06:27:12

Sweet. Then yes, why not have a downstairs computer? :)

It is a little scary - before when I watched the “I Love the __” shows on VH1, I never said (sometimes hadn’t heard of) the catch phrases they used between segments (jive turkey?). But as a true child of the 90’s, several of those words (including sweet) are definitely in my lexicon.

bryan2004-07-14 08:27:52

I, too, often use sweet. And “stoked.” And “bummed/bummer.” But I think these bridge many decades in their origins.

4141 Stevenson Blvd

Yesterday we struck out from our suburban wasteland to another suburban wasteland, slightly to the north and east. We knew where we wanted our apartment to be: somewhere inside a box described by Trader Joe’s, the BART station, and two major on-ramps to 680, which Leslie will be using to get to work. We tooled around all through the area, stopping at 5 or 6 places. Our options seemed to be of two strains: towards the middle of Fremont in 1970’s era apartments that universally lacked in-apartment laundry facilities, or right next to the BART station in brand-new, soulless giant complexes that, while they have in-apartment laundry, cost about $300/mo too much. We ultimately decided on a place owned by the same management company as our current apartment–they’ve been very good here in Santa Clara. The place is huge (over 1100 sqft), and for about the same as our current place was before they hiked the rate.

We move in two weeks. I’ll be investigating the possibilities of DSL and satellite television in the intervening time…


Comments

cameron2004-07-11 19:59:51

i like the new changing picture/overt at the top! i was wondering if you’d do something like that - i always liked the different overt lettering on the old design

bryan2004-07-11 21:20:33

i aim to please! I’m going to keep working on more. I didn’t realize you saw overt in it’s pre-last-summer incarnation.

wordpress

Here it is. It’s still not totally done, but close enough that I wanted to transfer all the old posts over. Please let me know if you encounter any errors or explosions or whatever. And yes, I’m going to change the pic up top…


Comments

cameron2004-07-08 16:50:45

Um…all the links/archives/search/etc on the right hand side are at the bottom of the page (at least in IE6)

i like the blue

bryan2004-07-08 17:26:31

damn you IE! i don’t have a windows machine to test it with. But i’ll try to find one.

bryan2004-07-08 17:48:09

okay… i borrowed leslie’s school laptop, which runs windows. I’m going to see if i can’t sort things out…

clare2004-07-08 18:01:02

IE balows

bryan2004-07-08 18:27:23

seems to look tolerable in IE now. Seriously, that browser is a huge security risk and a travesty of web standards. Use something better, safer, smaller, free and open source. Firefox!

cameron2004-07-08 19:56:42

done and done

i love the comment box!

leslie2004-07-08 20:11:55

Looks great! I love the yellow flowers pic. :)

bryan2004-07-08 22:37:48

cam - you tried Firefox? What do you think?

cameron2004-07-09 09:03:26

let’s see…i enjoy the tabs….why IE still doesn’t have them is a mystery to me - i always use them in safari on dad’s ibook. oh, and i was really impressed that it would play my online health lectures (which say you MUST use IE to view them and which none of the three different browsers on dad’s ibook could play)

i don’t know. everything seems to be going well. what else should i have noticed about its greatness?

bryan2004-07-09 09:20:49

Nothing in particular… I just figured because you were still using IE in this day and age that you must be die-hard or something :) One of my favorite things about firefox is the plugins. There’s the super-cool BugMeNot plugin that automatically gets bogus registration information for those “registration required” websites. There’s adblock that lets you right-click on any image or flash thingy and block it, and (maybe handy for you) there’s even ieview, that lets you right click to view a page in IE when you absolutely have to. I haven’t tried the last one, though, because it’s windows only.

em2004-07-11 07:58:46

The new look is fabu!!