Support

Account

Home Forums Front-end Issues if field has value within Field Group conditional statement Reply To: if field has value within Field Group conditional statement

  • My code is a little more complex. I tried to simplify code to get the point across.

    <?php
    
    echo '<table>';
    
    if( get_field('product_watts') ) {
    
        echo '<tr><td>' . '<strong>Wattage: </strong></td><td>'; 
        while ( have_rows('product_watts') ) : the_row();
        	 $array1[] = get_sub_field('watts')  .'w'; 
        endwhile;
        	$watts = implode(', ', $array1);
    
        echo $watts .'</td></tr>'; 
    }
    
    if( get_field('product_watt_replacement') ) {
    
        echo '<tr><td>' . '<strong>Wattage Replacement: </strong></td><td>'; 
        while ( have_rows('product_watt_replacement') ) : the_row();
        	 $array2[] = get_sub_field('watt_replacement')  .'w'; 
        endwhile;
        	$watt = implode(', ', $array2);
    
        echo $watt .'</td></tr>'; 
    }
    
    echo '</table>';
    
    ?>