How to hide custom field if it stays empty ?
-
Hi everybody,
I have different custom fields on listings and in single-page views, which can be filled through the backend.
Now I’m trying to hide all empty custom fields or rather where nothing has been entered because these fields are not needed in different cases.
Everything is working nice, but to hide the fields seems to be a bit tricky.
This is for example what I’ve tried at last:<li> <div class="customcontainer">Rental-Car:</div> <?php $Rentalcar = trim( get_post_meta($post->ID, "rentalcars", true) ); if( !empty( $Rentalcar ) ) : ?> <?php echo $Rentalcar ?> <?php else : // Output the info you want if source isn't set endif;?> </div> </li>
I’ve tried now different code-combinations..but I don’t get it to work.
Can please someone help?Thanks in anticipaton,
vamonos
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘How to hide custom field if it stays empty ?’ is closed to new replies.