Reloading Posts to WordPress

February 7th, 2011

Since witnessing the travesty that was GoDaddy’s Superbowl ads, I’ve never been more pleased to have moved to BlueHost.  That’s not to say that the transition was easy.

One of the WordPress sites that I moved had a large number of posts, and I really didn’t want to have to re-categorize them; but try as I might, I simply couldn’t get the category data to import correctly.  Due to some deployment issues I was working through, I didn’t want to import the entire database from the old deployment — just the bigger pieces of it.  I won’t bore you with the details — suffice it to say, it took me a few tries before I figured out the exact procedure to get this done.

Here are a few steps that you can take if you need to import your posts from one WordPress database to another without importing the complete database.

NOTE: Please make backups of all of your files before you follow any of these steps.  As with everything I post here, this is what worked for me — I can’t guarantee you’ll have the same results!

First: Export the tables you need.

I use PHPMyAdmin with XAMPP on my laptop for development.  You’ll need to adapt these directions in you’re using a different database tool.

Fire up XAMPP or log into PHPMyAdmin on your web server.  On the left, select the database from which you want to export your tables, and you should get a list of tables in that database.

Click on the Export tab.  Select these tables in the Export window:

  1. wp_commentdata
  2. wp_comments
  3. wp_postmeta
  4. wp_posts
  5. wp_terms
  6. wp_term_relationships
  7. wp_term_taxonomy

At the bottom, under Save as file, you can save the name template if you want, but it’s not necessary.  Since a lot of web servers will place file size limits on uploads, I recommend compressing with “gzipped” compression.  PHPMyAdmin will decompress the file automatically, and it significantly reduces the size of the file.

Click Go in the lower right corner, and you’ll get a backup file that includes those tables.  If you didn’t change the filename, it will be database_name.sql.gz.

Second: Clear the tables in the target database.

Now that you have what you need, log into the PHPMyAdmin interface on the web server where you’re uploading the data.  Click on the name of your database on the left, and you’ll be presented with a list of the tables on the Structure tab.

In the Action columns, go through the tables listed in the first step one by one, and click on the Empty icon (the trash can).  This will clear the contents of the tables, but leave them intact.

Once that’s done, click on the Import tab.  Under File to import, click on the Choose File button, and browse to the .sql.gz file that you exported earlier.

Click Go at the bottom right.  Once it’s finished, you should get a message telling you that the upload was successful.

That’s it!  Check your WordPress site, and all of the posts should be properly loaded and categorized.

Leave a Reply