There are two excellent plugins for handling multiple post thumbnails within WordPress, the Multiple Post Thumbnails plugin and the Multiple Featured Images plugin. Both are good, both do what they say they do and both are used by many people in the WordPress community. However, sometimes you may need to convert from one to the other, and they are unfortunately not compatible with one another.

To avoid having to manually copy over the images for every single post, simply use the same thumbnail ID when setting up the next plugin and run the following script (within a theme or plugin is fine) once and all of the images from the Multiple Post Thumbnails plugin will be be automagically converted for you 🙂 Note: You will need to change the thumbnail ID and the post type to match your own thumbnails.

<?php

$post_type = 'page'; // The post-type being processed (change this)
$id = 'secondary-image'; // The thumbnail ID (change this)

$args = array( 'posts_per_page' => -1, 'post_type' => $post_type );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) {
	$old = get_post_meta( $post->ID, $post_type . '_' . $id . '_thumbnail_id', true );
	if ( '' != $old ) {
		update_post_meta( $post->ID, 'kd_' . $id . '_' . $post_type . '_id', $old );
	}
}
die( 'Done! All Multiple Post Thumbnail images have been converted to work with the Multiple Featured Images plugin :)' );

?>

And if you want to go from the Multiple Featured Images plugin to the Multiple Post Thumbnails plugin, use the (almost identical) following script …

<?php

$post_type = 'page'; // The post-type being processed
$id = 'secondary-image'; // The thumbnail ID

$args = array( 'posts_per_page' => -1, 'post_type' => $post_type );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) {
	$old = get_post_meta( $post->ID, 'kd_' . $id . '_' . $post_type . '_id', true );
	if ( '' != $old ) {
		update_post_meta( $post->ID, $post_type . '_' . $id . '_thumbnail_id', $old );
	}
}
die( 'Done! All Multiple Post Thumbnail images have been converted to work with the Multiple Featured Images plugin :)' );

?>

Hopefully this code is of use to somebody out there!