-
-
Save jkudish/75ccbcf05d3a231f350e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
//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 ) ); | |
} | |
$existing_image = "http://guidevoyage.org.dev/wp-content/uploads/2012/02/Fontaine-de-Trevi.jpg"; | |
var_dump( getIDfromGUID( $existing_image ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment