Skip to content

Instantly share code, notes, and snippets.

@micahwave
Created May 16, 2012 18:50
Show Gist options
  • Select an option

  • Save micahwave/2712965 to your computer and use it in GitHub Desktop.

Select an option

Save micahwave/2712965 to your computer and use it in GitHub Desktop.
package migrate
function migrate_old_package( $post_id ) {
global $wpdb;
// fix all the slides
$slides = $wpdb->get_results( $wpdb->prepare("
SELECT * FROM $wpdb->posts AS s WHERE s.post_type = 'time_slide' AND s.post_parent = $post_id
"));
foreach( $slides as $slide ) {
$hub_id = get_post_meta( $slide->ID, 'time_hub_id', true );
$updated = wp_update_post( array(
'ID' => $slide->ID,
'post_parent' => $hub_id
));
if( $updated ) delete_post_meta( $slide->ID, 'time_hub_id' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment