Support

Account

Home Forums General Issues Hide Links That Have No Content Reply To: Hide Links That Have No Content

  • If this is the exact code you are using you’re missing your opening <?php on line 8 and the closing ?> on the last line. You also need to set the $title and $url variables if you haven’t already.

    <p><?php the_field('vendor'); ?></p>
    <p><?php the_field('manufacturer'); ?></p>
    <p><?php the_field('component'); ?></p>
    <p><?php the_field('component_description'); ?></p>
    <p><?php the_field('model_or_part_number'); ?></p>
    <p><?php the_field('part_classification'); ?></p>
    <p><?php the_field('information'); ?></p>
    
    <?php
    $attachment_id = get_field('upload_document'); // Get and set the ID
    $url = wp_get_attachment_url( $attachment_id ); // Get document url from ID
    $title = get_the_title( $attachment_id ); // Get Title from ID
    if( get_field('upload_document') ): //If the document field is populated do... ?>
      <a href="<?php echo $url; ?>" >Download File "<?php echo $title; ?>"</a>
    <?php endif; ?>
    
    <?php
    $attachment_id = get_field('upload_document_2'); // Get and set the ID
    $url = wp_get_attachment_url( $attachment_id ); // Get document url from ID
    $title = get_the_title( $attachment_id ); // Get Title from ID
    if( get_field('upload_document_2') ): //If the document field is populated do... ?>
      <a href="<?php echo $url; ?>" >Download File "<?php echo $title; ?>"</a>
    <?php endif; ?>
    
    <?php
    $attachment_id = get_field('upload_document_3'); // Get and set the ID
    $url = wp_get_attachment_url( $attachment_id ); // Get document url from ID
    $title = get_the_title( $attachment_id ); // Get Title from ID
    if( get_field('upload_document_3') ): //If the document field is populated do... ?>
      <a href="<?php echo $url; ?>" >Download File "<?php echo $title; ?>"</a>
    <?php endif; ?>