Skip to content

Instantly share code, notes, and snippets.

View MakarandMane's full-sized avatar
🎯
Focusing

Makarand Mane MakarandMane

🎯
Focusing
View GitHub Profile
@MakarandMane
MakarandMane / aa_URLtoAttachmentID.php
Created October 20, 2023 13:27 — forked from ahmadawais/aa_URLtoAttachmentID.php
Get the Attachment ID from an Image URL in WordPress
function pn_get_attachment_id_from_url( $attachment_url = '' ) {
global $wpdb;
$attachment_id = false;
// If there is no url, return.
if ( '' == $attachment_url )
return;
// Get the upload directory paths