Make custom field meta not display if there is not data in it

enter image description here

I current have a custom field that is displaying even if there is not data inputted in the meta box when posting.

How do I remove the hr, title, and ul if there is not data input?
Here’s the code I have currently to pull in the custom field:

<?php if( have_rows('google_drive_links') ): ?>
     <hr />
     <h3>Attachments</h3>
     <ul class="google-drive-links">
<?php while( have_rows('google_drive_links') ): the_row(); 
     // vars
     $content = get_sub_field('google_link_name');
     $link = get_sub_field('google_link'); ?>
     <li class="google-drive-link-item">
     <a target="_blank" href="<?php echo $link; ?>"><?php echo $content; ?></a>
    </li>
<?php endwhile; ?>
</ul>

Read more here:: Make custom field meta not display if there is not data in it

Leave a Reply

Your email address will not be published. Required fields are marked *