I wish to get the file path to files other than images like PDF or TXT that are uploaded. Should I use wp_get_attachment_image_src or there's other function more suited for non-image attachments.
I wish to get the file path to files other than images like PDF or TXT that are uploaded. Should I use wp_get_attachment_image_src or there's other function more suited for non-image attachments.
Share Improve this question asked Jan 26, 2022 at 3:44 ratib90486ratib90486 295 bronze badges1 Answer
Reset to default 3No, wp_get_attachment_image_src()
is for image files only. For non-image files, you can use get_attached_file()
to get the full filesystem path to the attachment file. And to get the full URL, you can use wp_get_attachment_url()
.