Display links to download attached files
-
Hi,
This is the first time I am using Pods in one of my websites.
I created a custom post type and a custom field to upload different PDF files for each post. So far everything is perfect. However after spending many hours in vain looking for a way to display download links in the single page I decided to post my problem here hoping that someone could help me out.
By the way I created a Pods template named ‘job_post_attachments’ with the following:
<?php $files = $obj->field('post_attachments'); foreach ( $files as $file ) { $url = wp_get_attachment_url( $file['ID'] ); $filename = basename ( wp_get_attachment_url( $file['ID'] )); echo '<a href="'.esc_url($url).'">'.$filename.'</a><br>'; } ?>
And in the single page I call that template via this shortcode:
[pods name="job" template="job_post_attachments"]
The results are shown but the problem it displays all the attachments including the ones attached to other posts instead of showing only the ones specific to the currently viewed post.
How would I limit it to show only attachments of current posts
Thanks in advance
- The topic ‘Display links to download attached files’ is closed to new replies.