Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Gabriel Ward
Gabriel Ward
20,222 Points

displaying files in a custom post

I've created a custom field in a custom post type, to display pdf files. The field type is 'file'.

I've got the return value set to 'File URL' and it doesn't seem to be working. Say I have a pdf file titled March Newsletter, then I'd like a link with text the text March Newsletter to display. And when you click that the pdf file opens. All that displays is the file's location for example

http://localhost:8888/wordpress%203/wp-content/uploads/2015/07/March-Newsletter-20151.pdf

and it's not a link.

Any help would be much appreciated.

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

I'm not exactly sure what the markup is here, since you have the URL, couldn't you output the URL into an anchor in your view? Something like

<a href ="<?php custom_post_url(); ?>">View PDF</a>
Gabriel Ward
Gabriel Ward
20,222 Points

Hi Kevin,

I'm setting this up for a client, so ideally they'd just be able to go into the custom post type and click the add file button. Thanks for that suggestion though