×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: schos holler
Added: Jun 21, 2017 1:14 PM
Modified: Jun 26, 2017 7:37 AM
Views: 13
Tags: wordpress
  1. // retrieves the attachment ID from the file URL
  2. function pippin_get_image_id($image_url) {
  3.         global $wpdb;
  4.         $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
  5.         return $attachment[0];
  6. }
  7.