Skip Navigation

[Resolved] View using Media as post type – how can I retrieve the File URL for a PDF

This support ticket is created 2 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by philippeS-4 2 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2438943

Hi there,

I have a view which parse the Media post type filtered by a taxonomy and I would like to retrieve the File URL and not the post URL - this is for PDF files in the media library?

So basically I am looking to retrieve something like this - hidden link

So that I can use it in an href tag.

I saw a ticket in 2013 saying it wasn't possible, hoping that in almost 10 years we have a solution or workaround.

Thanks,
Phil

#2439043

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Phil,

Thank you for getting in touch.

Are you using a Types shortcode in your view to display the PDF file?

If so then you should be able to do this.


[types field="my-file" output='raw'][/types]

Where my-file is the slug of your custom field.

Thanks,
Shane

#2439055
Screenshot 2022-08-16 at 20.54.48.png
Screenshot 2022-08-16 at 20.41.01.png

Hi Shane,

Thanks for coming back to me, I have tried to use the shortcode provided but it doesn't work. This is not from a CPT but from the standard WP Media file as per attached picture.

I have this basic code to the view and you can see the result here - hidden link
I am not getting the file url as per snapshot.

What am I doing wrong?
Thanks,
Phil

<p>This is the title of the file: [wpv-post-title]</p>
<p>This is the slug of the file: [wpv-post-slug]</p>
<p>This is the file URL: [types field="[wpv-post-slug]" output='raw'][/types]</p>
#2439125

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Philippe,

Your view is displaying the media post type ?

The closest thing you can do is this.

[wpv-post-url]

Adding the file extension to the end of the url.

We don't have a way to display those fields from the media library.

Thanks,
Shane

#2440235

My issue is resolved now. Thank you!