Support

Account

Home Forums General Issues Detect if field is hidden by conditional logic Reply To: Detect if field is hidden by conditional logic

  • You can also name a select field $footer with options yes/no. Then just do a conditional statement based on the $footer value.

    <?php
    
    if(get_field('$footer') == "yes")
    {
        //...
    } else {
    
       //...
    }
    
    ?>

    or just

    <?php if( get_field('$footer') ): ?>
    	 //...
    <?php endif; ?>

    As far as returning null, you can skip the option to show the footer and just check if data has been entered into each of the footer column fields. If no, the field wont show.

    <?php 
      
      $col_1 = get_field('$footer_col_1');
      $col_2 = get_field('$footer_col_2');
      $col_3 = get_field('$footer_col_3');
    
      if($col_1) {
    	echo $col_1;
      }
    
      if($col_2) {
    	echo $col_2;
      }
    
      if($col_3) {
    	echo $col_3;
      }
    
    ?>

    Lots of options, so just go with the method that works best for you.