0

First of all i am sorry if my question is not correct formulated, i am new in to wordpress and php. I hope i am not being too silly.

i have this:

<div class="propsmeta clearfix">
        <div class="propslist"><span>Locatie- </span> <span class="propval"> <?php echo get_the_term_list( $post->ID, 'location', '', ' ', '' ); ?></span></div>
        <div class="propslist"><span>Tip proprietate- </span> <span class="propval"><?php echo get_the_term_list( $post->ID, 'property', '', ' ', '' ); ?></span></div>
        <div class="propslist"><span>Camere - </span> <span class="propval"> <?php echo get_the_term_list( $post->ID, 'bedrooms', '', ' ', '' ); ?></span></div>
        <div class="propslist"><span>Băi - </span> <span class="propval"> <?php $bath=get_post_meta($post->ID, 'wtf_bath', true); echo $bath; ?></span></div>
        <div class="propslist"><span>Garaj - </span> <span class="propval"> <?php $garage=get_post_meta($post->ID, 'wtf_garage', true); echo $garage; ?></span></div>
        <div class="propslist"><span>Pret- </span> <span class="propval"> <?php $price=get_post_meta($post->ID, 'wtf_price', true); echo $price; ?></span></div>
        <div class="propslist"><span>Suprafata- </span> <span class="propval"> <?php $suprafata=get_post_meta($post->ID, 'wtf_suprafata', true); echo $suprafata; ?></span></div>
    </div>

I want if the input data is empty i don't want to be desplayd in the main div

For example if the bath input data is left empty i want the:

<div class="propslist"><span>Băi - </span> <span class="propval"> <?php $bath=get_post_meta($post->ID, 'wtf_bath', true); echo $bath; ?></span></div>

not to appear anymore

0
<?php $bath=get_post_meta($post->ID, 'wtf_bath', true); 
if(!empty($bath) ) { ?>

<div class="propslist"><span>Băi - </span> <span class="propval"> <?php  echo $bath; ?></span></div>

<?php } ?>

Do something like this for each div !.. only display div if the data to be displayed in div is not empty !

0

Try this:

<?php $bath=get_post_meta($post->ID, 'wtf_bath', true);
  if ($bath) { ?>
 <div class="propslist"><span>Băi - </span> <span class="propval"> <?php echo $bath; ?></span></div>
<?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.