There’s never been an easy way to migrate from the WebComic plugin to Comic Easel – mainly because I don’t use the webcomic plugin so I never had a test site to be able to create something.

Thanks to James Dooley (@SmSLDoo on twitter) I had an opportunity today to get the exact database names and what taxonomy names are used and I came up with this bit of code:

/***
 * 1) Install and activate the Comic Easel plugin WITH webcomic stil active.
 * 2) In your browser bar you would type http://yoururl.com/?wc2ce&name=webcomic1
 * * the webcomic1 denotes the first comic in the webcomic plugin, there are several webcomic sets up, but they're always incremented by 1
 * so the next comic that was setup would be webcomic2  so  /?wc2ce&name=webcomic2  would trigger the migration of that one
 * 3) once you do that it should pause a few while loading your site, once it's done your site will finish loading. 
 * 4) Deactivate the webcomic plugin and switch to the comicpress theme.
 * 5) verify the comics are all there, the characters have been migrated and the storyline's are all chapters
 * **/


if ( isset( $_GET['wc2ce'] ) )
	add_action( 'template_redirect', 'ceo_convert_to_ce' );

function ceo_convert_to_ce() {
	global $wpdb;
	if (isset($_REQUEST['name'])) {
		$name = esc_attr($_REQUEST['name']);
		if (!empty($name)) {
			// SQL Convert the characters and story
			$sql = "UPDATE {$wpdb->term_taxonomy} SET taxonomy='characters' WHERE taxonomy='".$name.'_character'."';";
			$wpdb->query($sql);
			$sql = "UPDATE {$wpdb->term_taxonomy} SET taxonomy='chapters' WHERE taxonomy='".$name.'_storyline'."';";
			$wpdb->query($sql);
			// ---
			$args = array(
					'posts_per_page'   => -1,
					'orderby'          => 'post_date',
					'order'            => 'DESC',
					'post_type'        => $name,
					'post_status'      => 'any',
					'suppress_filters' => true 
					);
			$qposts = get_posts( $args );
			// Loop through all posts and set whatever attachment is first found as the featured image
			foreach ($qposts as $qpost) {
				$attachments = get_posts(array(
							'post_type' => 'attachment', 
							'post_mime_type'=>'image', 
							'posts_per_page' => 0, 
							'post_parent' => $qpost->ID, 
							'order'=>'ASC'
							));
				if ($attachments) {
					foreach ($attachments as $attachment) {
						set_post_thumbnail($qpost->ID, $attachment->ID);
						break;
					}
				}
			}
			// Now set all comics as the 'comic' post type in one fell swoop.
			$sql = "UPDATE {$wpdb->posts} SET post_type='comic' WHERE post_type='".$name."';";
			$wpdb->query($sql);
		}
	}
}

This code will be commented out inside the wp-content/plugins/comic-easel/functions/redirects.php file starting with version 1.8.2 of Comic Easel, you could either copy – paste this code into the functions.php of your theme or uncomment it inside the plugin itself.

How it works is you type in your browser, in the url line your sitename with /?wc2ce&name=webcomic1 at the end of it, then you press enter and it will do the work for you, the webcomic1 denotes the first webcomic that is made with webcomic plugin, to do the other’s you would change webcomic1 to webcomic2 or webcomic3 until all of your comics are moved

If you look at the code, the reason it’s not ‘open all the time’ is because it makes direct SQL queries, don’t want to accidentally keep doing that over and over.

It changes the actual names inside the database from webcomic# to ‘comic’ or ‘chapters’ or ‘characters’. The loop inside of the function takes the comic that was just ‘normal’ attached and makes that comic the featured image.

Of course, if you ever need any help doing this I would be glad to assist.

– Phil