Home › Forums › General Issues › Hide Links That Have No Content › Reply To: Hide Links That Have No Content
if get_field('upload_document'){ . '<p><a href="' . get_field('upload_document') . '" target="_blank" class="readmore">Download PDF → </a></p>' . };
Yes it is possible to use the title from the uploaded document, but you’ll need to set the field to return the File ID instead of the File URL. With the ID you can retrieve the values like this…
<?php
$attachment_id = get_field('upload_document');
$url = wp_get_attachment_url( $attachment_id );
$title = get_the_title( $attachment_id );
if( get_field('field_name') ):?>
<a href="<?php echo $url; ?>" >Download File "<?php echo $title; ?>"</a>
<?php endif; ?>
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.