Support

Account

Home Forums General Issues hide div if nothing in fields Reply To: hide div if nothing in fields

  • Not sure why my original answer got marked as private but here’s what I originally provided as solution:

    <?php if( get_field('preco') && get_field('checked')): ?>
    <div class="container"> 
    	<div class="row">
    		<div class="col">
    			<?php if( get_field('preco') ): ?>
    			<p> <?php the_field('preco'); ?> </p>
    			<?php endif; ?>
    		</div>
    	
    		<div class="col">
    			<?php $ratingstar = get_field('checked'); ?>
    			<span class="fa fa-star <?php if ($ratingstar >= 1) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar >= 2) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar >= 3) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar >= 4) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar == 5) { echo 'checked';}?>"></span>
    		</div>
    	</div>
    </div>
    <?php endif; ?>

    The “if” condition in the first line (together with “endif” in the last line) hide the content if there is no value.