Get Attachment URL By ID in WordPress

To get the attachment (media) URL by ID in WordPress, first, you need to find the ID. To do this, go to Media and click on the image. In the page URL, you will see the ID in front of the post.

In this example, the ID is 68.

Add the ID in function to retrieve the URL for an attachment.


You can get the URL like below.
Shopping Cart