Last active
September 13, 2015 17:35
-
-
Save danielpataki/d195ce8feaba5b01533e to your computer and use it in GitHub Desktop.
Migrate From Media Custom Fields to ACF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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