I am trying to download a PDF which has been uploaded through the File Field Type. I’ve followed all the instructions here
The link is being created but the source of that link is not pointing to the source of the file.
I am not quite understanding the structure of the URL.
What is different in my WP setup is the media files are being stored outside of WordPress inside a folder called “files” and perhaps this is what is causing the problem.
Here’s the code I am using:
$attachment_id = get_field(‘download_label_afrikaans’);
$url = wp_get_attachment_url( $attachment_id );
<?php if( get_field(‘download_label_english’) ): ?>
<?php endif; ?>
Thanks for getting back to me. I’ve deleted the two posts that talked about images so as not to confuse matters.
I’ve since also reverted back to the “wp-content/uploads” folder to simplify matters so I don’t need to worry about the WP PATH constants as mentioned (is my thinking correct?)
My understanding therefore is as follows:
<?php if( get_field('download_label_english') ): ?> <a class="label-en" href="<?php the_field('download_label_english'); ?>"><span></span>Label (ENG)</a> <?php endif; ?>
But I still get an array URL even though I am not going the array route.
Right, so what I have done is created a blank WP site. Added ACF, and in my theme page added
<a href="<?php the_field('gallery_file'); ?>" >Download File</a> where “gallery_file” is the name of the test field.
This has worked 100% as expected when a refreshed the page so now I am trying to figure out what I have done wrong with my other project.
Is it possible that by setting the “wp-content/uploads” to use a different folder by using
define( 'UPLOADS', ''.'files' ); I have effectively changed all the paths on a permanent basis and if that is the case, how do I undo this so that it points back to “wp-content/uploads”
The topic ‘File download URL incorrect. Cannot download uploaded file.’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.