Title: robcolburn's Replies | WordPress.org

---

# robcolburn

  [  ](https://wordpress.org/support/users/robcolburn/)

 *   [Profile](https://wordpress.org/support/users/robcolburn/)
 *   [Topics Started](https://wordpress.org/support/users/robcolburn/topics/)
 *   [Replies Created](https://wordpress.org/support/users/robcolburn/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/robcolburn/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/robcolburn/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/robcolburn/engagements/)
 *   [Favorites](https://wordpress.org/support/users/robcolburn/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Need to get attachment ID by Image URL](https://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url/)
 *  [robcolburn](https://wordpress.org/support/users/robcolburn/)
 * (@robcolburn)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url/page/2/#post-1796344)
 * Thanks webord,
 * Very helpful right now. BTW: you may want to escape the url. For my purposes,
   I needed to.
 * `$id = $wpdb->get_var($wpdb->prepare("SELECT wposts.ID FROM $wpdb->posts wposts,
   $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key
   = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = '
   attachment'", $url));`

Viewing 1 replies (of 1 total)