• i currently have two custom fields but they show up even when there is nothing in their value box to show. I would like to hide the custom fields that are empty…this is the code that im using now…hope some one can just help me with that.. thank you.

    <?php if(is_single() ) { ?>
    <h6 class="meta-field">Source : <?php $text = get_post_meta( get_the_ID(), 'Mood', TRUE );
    echo make_clickable( $text ); ?></h6>
    <h7 class="meta-field">Via : <?php $text = get_post_meta( get_the_ID(), 'Style', TRUE );
    echo make_clickable( $text ); ?></h7>
    <?php } ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • try (untested):

    <?php if(is_single() ) {
    if( get_post_meta( get_the_ID(), 'Mood', TRUE ) ) { ?>
    <h6 class="meta-field">Source : <?php $text = get_post_meta( get_the_ID(), 'Mood', TRUE );
    echo make_clickable( $text ); ?></h6>
    <?php }
    if( get_post_meta( get_the_ID(), 'Style', TRUE ) ) { ?>
    <h7 class="meta-field">Via : <?php $text = get_post_meta( get_the_ID(), 'Style', TRUE );
    echo make_clickable( $text ); ?></h7>
    <?php }
    } ?>
    Thread Starter deltamatrix

    (@deltamatrix)

    It did not work. But i had added and changed couple of other stuff too. here is what im currrently using now.

    <?php if(is_front_page() || is_category() || is_tag()  ) { ?>
    <?php wpsocialite_markup(); ?>
    <?php } ?>
    <?php if(is_single() ) { ?>
    <h6 class="meta-field">Source : <?php $text = get_post_meta( get_the_ID(), 'Source', TRUE );
    echo make_clickable( $text ); ?></h6>
    <h7 class="meta-field">Via : <?php $text = get_post_meta( get_the_ID(), 'Via', TRUE );
    echo make_clickable( $text ); ?></h7>
         <h4 class="meta-category"> Category : <?php the_category(' » '); ?> </h4>
         <h5 class="meta-tags"> Tags : <?php the_tags('  '); ?></h5>
    <?php } ?>

    it is the same thing just added a couple of headers and changed the custom fields name. I put your code under mine and it did not work.
    Thank you so much for replying to issue, all i need is to hide the custom fields when empty. hope we can figure this out..

    Thread Starter deltamatrix

    (@deltamatrix)

    i figured it out. Thank you for your response.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘HIDE Custom Fields’ is closed to new replies.