I want to link a Post Title to the PDF. I feel my solution is somewhere in wp_get_attachment_url()
but I can't figure out how. Also, I'd like my pdf to be located in ../wp-content/uploads/year/month/pdf-name.pdf
for about 12 post going back 2 years. Please point me in the right direction. Thanks.
I want to link a Post Title to the PDF. I feel my solution is somewhere in wp_get_attachment_url()
but I can't figure out how. Also, I'd like my pdf to be located in ../wp-content/uploads/year/month/pdf-name.pdf
for about 12 post going back 2 years. Please point me in the right direction. Thanks.
- I think this may be of some assistance, hopefully. Good Luck! stackoverflow/questions/19949381/… – mr__culpepper Commented Dec 8, 2016 at 20:23
- The Page Links To plugin should take care of that without excess bloat. – Knut Sparhell Commented Oct 7, 2019 at 8:50
1 Answer
Reset to default 1I recommend using the plugin Advanced Custom Fields (Very popular plugin). It lets you create fields and manage their values very easily.
This way you could just create a new field for file upload and then to pull its information like this-
<?php
$my_file = get_field('my_file');
if( $my_file ) {
echo $my_file['url'];
echo $my_file['alt'];
echo $my_file['...
}
?>