Skip to content

Instantly share code, notes, and snippets.

@aliciaduffy
Created March 2, 2015 15:41
Show Gist options
  • Save aliciaduffy/bec29034d8eb53298c65 to your computer and use it in GitHub Desktop.
Save aliciaduffy/bec29034d8eb53298c65 to your computer and use it in GitHub Desktop.
$old_credits = array();
$old_credits[] = get_metadata('post', 275142, '_media_credit', true);
$old_credits[] = get_metadata('post', 275142, '_media_credit_2', true);
$old_credits[] = get_metadata('post', 275142, '_media_credit_3', true);
if ( $old_credits ) {
$number = 0;
$number_credits = count($old_credits);
add_metadata( 'post', 275142, 'media_credit', $number_credits );
add_metadata( 'post', 275142, '_media_credit', 'field_548e1e18a4b85' );
foreach ( $old_credits as $old_credit ) {
add_metadata( 'post', 275142, 'media_credit_' . $number . '_credit', $old_credit );
add_metadata( 'post', 275142, '_media_credit_' . $number . '_credit', 'field_548e1e21a4b86' );
$number++;
}
}
$old_credit_link_1 = get_metadata('post', 275142, '_media_credit_link', true);
if ($old_credit_link_1 ) {
add_metadata( 'post', 275142, 'media_credit_0_credit_link', $old_credit_link_1 );
add_metadata( 'post', 275142, '_media_credit_0_credit_link', 'field_548e1e28a4b87' );
}
$old_credit_link_2 = get_metadata('post', 275142, '_media_credit_link_2', true);
if ($old_credit_link_2 ) {
add_metadata( 'post', 275142, 'media_credit_1_credit_link', $old_credit_link_2 );
add_metadata( 'post', 275142, '_media_credit_1_credit_link', 'field_548e1e28a4b87' );
}
$old_credit_link_3 = get_metadata('post', 275142, '_media_credit_link_3', true);
if ($old_credit_link_3 ) {
add_metadata( 'post', 275142, 'media_credit_2_credit_link', $old_credit_link_3 );
add_metadata( 'post', 275142, '_media_credit_2_credit_link', 'field_548e1e28a4b87' );
}
$my_post = array(
'ID' => 275142
);
wp_update_post( $my_post );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment