how not to show an empty field (single.php)
-
I have created two new fields for each post ( “Customer” and “Customer2”) and I would like them to be shown at the top of the post if there is something inside, otherwise I would like them to be hidden.
I’ve tried to modify the single.php file writing this:<div class="postmeta"> <span class="customer"> Customer: <?php echo get_post_meta( get_the_ID(), 'Customer', true); ?></span> <br /> <span class="customer2"> Secondary Customer: <?php echo get_post_meta( get_the_ID(), 'Customer2', true); ?></span> </div>
this way both the fields are correctly shown, but how can I hide them if they are empty (I mean, sometimes I don’t have anything to write in “Customer” or in “Customer2”)
could you help me ?
I started recently to play with codes, so please be patient!!
M2
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘how not to show an empty field (single.php)’ is closed to new replies.