How do you find a file in the media library using the file URL?
Based on my research, you would need to run a query on directly on the database using WPDB. So you would do something like this: Add this in your functions.php file: // retrieves the attachment ID from the file URL function get_image_id($image_url) { global $wpdb; $the_attachment = $wpdb->get_col($wpdb->prepare(“SELECT ID FROM $wpdb->posts WHERE guid=’%s’;”, $image_url )); … Read more