Skip to content

Instantly share code, notes, and snippets.

@danielpataki
Last active September 13, 2015 17:35
Show Gist options
  • Save danielpataki/d195ce8feaba5b01533e to your computer and use it in GitHub Desktop.
Save danielpataki/d195ce8feaba5b01533e to your computer and use it in GitHub Desktop.
Migrate From Media Custom Fields to ACF
$args = array(
'post_type' => 'attachment',
'post_status' => 'any',
'posts_per_page' => -1
);
$attachments = new WP_Query( $args );
while ( $attachments->have_posts() ) {
$attachments->the_post();
// Media Custom Field Data
$medium = get_post_meta( get_the_ID(), 'tqmcf_medium', true );
$size = get_post_meta( get_the_ID(), 'tqmcf_size', true );
$price = get_post_meta( get_the_ID(), 'tqmcf_price', true );
$sold = get_post_meta( get_the_ID(), 'tqmcf_sold', true );
// New ACF Data
update_field( 'medium', $medium, get_the_ID() );
update_field( 'size', $size, get_the_ID() );
update_field( 'price', $price, get_the_ID() );
update_field( 'sold', $sold, get_the_ID() );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment