Support

Account

Home Forums Add-ons Repeater Field Display a field only if populated Reply To: Display a field only if populated

  • Hi @Permanence

    Have you read the code exmaples for conditional logic / understand what an if statement in PHP is?

    Your code should look more like this:

    
    <?php while(the_repeater_field('content_block')): ?>
    <div class="clearfix">
    <?php if( get_sub_field('title') ): ?>
    	<h2><?php the_sub_field('title'); ?></h2>
    <?php endif; ?>
    <div class="img"><img src="<?php the_sub_field('image'); ?>"></div>
    <div class="txt"><?php the_sub_field('content'); ?> </div>
    </div>
    <?php endwhile ?>