Migrating to New WP

There is a pretty old, rickety WP site that I want to migrate some data from to a new WP install.

There are “instructors” who are “pages” with a parent page. There are a couple of free/commercial plugins: WP ALL EXPORT and WP ALL IMPORT, but they really want you to pay $99 each, if not more.

Found a cool way to export just those pages:

First we find the ID number of the parent page that we want to export. This process will export that page and all its sub-pages (children), sub-sub-pages, etc. You can find this by hovering over the “Edit” link in the WordPress “Pages/Edit” area and noting the “&post=number” section. In my case it was “2” — that’s the number we will use below.

In wp-admin/includes/export.php, find following lines:

// grab a snapshot of post IDs, just in case it changes during the export
$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");

And replace with:

# Export only a particular page and all its children
$post_ids = array();
$new_pages = array();
$new_pages[] = 2; # Parent page ID, which we will export, along with all its children
while (count($new_pages)) {
  $where = "WHERE post_parent IN (".join(',', $new_pages).")";
  foreach ($new_pages as $np) {
    $post_ids[] = $np;
  $new_pages = array();
  $new_pages = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
# $post_ids array now contains the pages we wish to export

I tried this but it only exported the parent page. I could see if the WP codebase has changed, but for now just modifying the Instructors pages in bulk to have a specific, unique “author”, and will export only the pages with that author.

But it didn’t import and download the attached files! So I tried exporting the media vie the wordpress exporter, which, once I had increased some of the php resources via php.ini, or in GoDaddy case a file called .user.ini:

upload_max_filesize = 6M
post_max_size = 32M
memory_limit = 300M
file_uploads = On
max_execution_time = 180

Seemed to work, except that none of the images were there. So I copied the uploads directory from previous install. Now the images were there, but not visible as thumbnails in the WP Media interface. First I tried using the regenerate-thumbnails plugin, then looked into the WP -> Settings -> Media and updated the path there. Still no luck. Came across a plugin called Force Regenerate Thumbnails which looks like it might be doing the trick. Quite time-consuming, though.

I have already switched the Instructors from pages to the post type, instructor, created with the custom-post-type-ui plugin and migrated with the post-type-switcher plugin.

Now I want to create a featured image for each instructor, which I will probably do manually, comparing the former image with ones in our library.