Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2015 19:01
Show Gist options
  • Save anonymous/9c2920adc65efb308340 to your computer and use it in GitHub Desktop.
Save anonymous/9c2920adc65efb308340 to your computer and use it in GitHub Desktop.
$existing_image = "http://guidevoyage.org.dev/wp-content/uploads/2012/02/Fontaine-de-Trevi.jpg";
//Locate the attachment post's ID in the database based on the GUID.
function getIDfromGUID( $existing_image ){
global $wpdb;
return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=attachment AND guid=%s", $existing_image ) );
var_dump($wpdb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment