Support

Account

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; ?>