Support

Account

Home Forums Add-ons Repeater Field Make repeater field meta not display if there is not data in it

Helping

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

  • 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') ): ?>
        <?php while( have_rows('google_drive_links') ): the_row(); 
             // vars
             $content = get_sub_field('google_link_name');
             $link = get_sub_field('google_link'); ?>
             <hr />
             <h3>Attachments</h3>
             <ul class="google-drive-links">
             <li class="google-drive-link-item">
             <a target="_blank">"><?php echo $content; ?></a>
            </li>
        </ul>
        <?php endwhile; ?>
    <?php endif; ?>
  • Looks like I had part of my code wrong. Here’s what I’m currently using:

    <?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>
    <?php endif; ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Make repeater field meta not display if there is not data in it’ is closed to new replies.