Created
July 2, 2016 11:54
-
-
Save mikeselander/e5c24d18a8305960c867e7e455839e32 to your computer and use it in GitHub Desktop.
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
private function update_meta_ids( $pid ){ | |
global $wpdb; | |
$img_id = get_post_meta( $pid, cmb_prefix( get_post_type( $pid ) ) . 'image_id', true); | |
$img = get_post_meta( $pid, cmb_prefix( get_post_type( $pid ) ) . 'image', true); | |
if ( empty( $img_id ) && ! empty( $img ) ){ | |
$image = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $img ) ); | |
if( ! empty( $image ) ) { | |
update_post_meta( $pid, cmb_prefix( get_post_type( $pid ) ) . 'image_id', $image[0] ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment