Any way to hide meta field not filled?

This topic contains 3 reply and 2 voices, and was last updated by Tareq Hasan 10 years, 11 months ago
Viewing 3 Posts - 1 through 3 (of 3 total)
Author Posts
April 30, 2013 at 2:42 pm 3024
Tareq Hasan Hello Tareq, I've inserted into post template some codes to show meta field like these: <?php echo get_post_meta( $post->ID, 'name1', true ); ?> <?php echo get_post_meta( $post->ID, 'name2', true ); ?> There's some way to hide in post page this field if they aren't filled by user? Thank you.
April 30, 2013 at 2:44 pm 3025
Tareq Hasan Tareq Hasan

You can use it like that –

<?php
if( $name1 = get_post_meta( $post->ID, 'name1', true ) ) {
    echo $name1;
}
?>
April 30, 2013 at 4:07 pm 3031
s.pezzani s.pezzani

Wow! Thank you Tareq for your kindness.

And congratulations again for this amazing plugin.

April 30, 2013 at 4:16 pm 3032
Tareq Hasan Tareq Hasan

Would you be able to give us a testimonial?

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