Home Forums ACF PRO Hide repeater Sub Fields


Hide repeater Sub Fields

  • Hi I have a definition list which i am trying to hide the <dt> and <dd> for specific repeater fields that do not have any content. I have tried a few different approaches in the forum but none seem to be working for me.

    So I need it to hide the dd and corresponding dt. For example I want to hide the engine sub_field and also the engine <dt>. Any help would be wonderful!

    <!-- model specifications -->
        	    						<?php if( have_rows('model_specifications') ): ?>
        								<div id="model-specifications">
        										<dt class="model">Model</dt>
        										<dt class="gpm">GPM</dt>
        										<dt class="psi">PSI</dt>
        										<dt class="drive">Drive RPM</dt>
        										<dt class="hp-volt">HP / Volt</dt>
        										<dt class="engine">Engine</dt>
        										<dt class="request-quote">Quote</dt>
     										<?php while( have_rows('model_specifications') ): the_row(); ?>
           										<dd class="model"><?php the_sub_field('model'); ?></dd>
    											<dd class="gpm"><?php the_sub_field('gpm'); ?></dd>
           										<dd class="psi"><?php the_sub_field('psi'); ?></dd>
           										<dd class="drive"><?php the_sub_field('drive'); ?></dd>
           										<dd class="hp-volt"><?php the_sub_field('hp-volt'); ?></dd>
           										<dd class="engine"><?php the_sub_field('engine'); ?></dd>
           										<dd class="request-quote"><a href="/request-a-quote/">Request Quote</a></dd>	
            								<?php endwhile; ?>
            								<p><?php the_field('model_specification_notes'); ?></p>
     									<?php endif; ?>												
        								<!-- end model specifications -->
  • it is possible, just check if value is there
    but for that you need to re-arrange / re-write your code.
    here a part of it. just add the other rows the same way.

    <?php if( have_rows('model_specifications') ):
    while( have_rows('model_specifications') ): the_row(); 
     $ms_model = get_sub_field('model');
     $ms_gpm = get_sub_field('gpm');
     echo '<div id="model-specifications">';
     echo '<dl>';
     if ($ms_model) {echo '<dt class="model">Model</dt>';}
     if ($ms_gpm) {echo '<dt class="gpm">GPM</dt>';}  
     if ($ms_model) {echo '<dd class="model">'.$ms_model.'</dd>';}
     if ($ms_gpm) {echo '<dd class="gpm">'.$ms_gpm.'</dd>';}
     echo '</dl>';
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Hide repeater Sub Fields’ is closed to new replies.