The generic function in WordPress to get a file attachment URL from an attachment ID is wp_get_attachment_url()
.
Pods stores file/image/videos in the field as the ID of the attachment.
So if a field is name file_field
and one is writing in PHP in the current loop,
echo wp_get_attachment_url(
get_post_meta( get_the_ID(), 'file_field', true )
);
…will output the URL for the image in that field for the current post object in the loop.
The third argument of get_post_meta()
, true
, indicates that one ID is expected for one file. If it is set to false
, get_post_meta
will return an array of IDs, which can be iterated in a loop to be passed to wp_get_attachment_url()
The Pods equivalent of get_post_meta()
is pods()->field()
https://docs.pods.io/code/pods/field/ …where pods()
takes the post type an optional slug, ID, or other arguments, and field
takes the field name, whether it is singular or not, and whether to return the raw ID/value, or a formatted value.
The magic tag equivalent is {@file_field._src}