WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Repeatable field and conditional logic (1 post)

  1. iamjustoneman
    Member
    Posted 11 months ago #

    Hi all,

    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.

    Thanks

    http://wordpress.org/plugins/advanced-custom-fields/

Reply

You must log in to post.

About this Plugin

About this Topic