I am using ACF for some straightforward frontend output, all I am try to do is output a series of clients, some have case studies on my site, some don’t. At the minute, my code always displays a link, even if a case study doesn’t exist. I just need some help in adding some conditional logic so that the link doesn’t show if there isn’t a case study.
<?php if(get_field('clients')): ?> <div class="col clients boxed"> <h3>Clients</h3> <ul id="client-list"> <?php while(has_sub_field('clients')): ?> <li> <a href="<?php the_sub_field('case_study_page'); ?>"> <?php the_sub_field('client_name'); ?> </a> </li> <?php endwhile; ?> </ul> </div> <?php endif; ?>
Appreciate any help.
- The topic ‘Repeatable field and conditional logic’ is closed to new replies.