Support

Account

Home Forums Backend Issues (wp-admin) How to hide a field if its empty

Solved

How to hide a field if its empty

  • Hello all, what I’m trying to do is hide a field if it’s empty and doesn’t pertain to that particular product description. Below is my code so far. Any help would be appreciated, thank you!

    <section class="lining">
       <label class="label_left">Lining Color : </label>
        <?php
    								 
    	$values = get_field('lining_color');
    	if($values)
    	{
    	  echo '<select name="lining-color">';
    								 
    	  foreach($values as $value)
    	  {
    	  echo '<option>' . $value . '</option>';
    	  }
    								 
    	  echo '</select>';
    	}
    														 
    	?>				
    </section>			
    
    
  • Hi @davidzupec

    Looks like you already have an if statement which looks if the value exists, so this should already solve your question.

    Can you please be a bit more specific as to what you need help with?

    Thanks
    E

  • Thanks for responding Elliot, I didn’t realize I already had it figured out : )

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘How to hide a field if its empty’ is closed to new replies.