Last active
May 21, 2017 23:42
-
-
Save kachi/313242fa8b1a1889a33ed81d7e376e62 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
<?php | |
//https://pippinsplugins.com/retrieve-attachment-id-from-image-url/ | |
function pippin_get_image_id($image_url) { | |
global $wpdb; | |
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url )); | |
return $attachment[0]; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment