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