Just wondering, I’m creating a multi-vendor website. So far it has all been going well, however we have a need to display icons as badges if a field contains data.
Here is an example of the code:
<li class="location clearfix"> <div class="pull-left"> <span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span> </div> <div class="pull-right"> <?php echo $abn; ?> </div> </li>
When displaying the field abn
it appears fine, although we are wanting an icon displayed if abn
contains data. We are needing the Echo to be an IF statement, that if the profile “abn“` field contains data, that an icon is displayed.
Just wondering, is there any examples that anyone would have using an existing script?
Thanks for helping!
Advertisement
Answer
Try this, add if condition with !empty()
<?php if(!empty($abn)) {?> <li class="location clearfix"> <div class="pull-left"> <span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span> </div> <div class="pull-right"> <?php echo $abn; ?> </div> </li> <?php } ?>
you can add this if condition wherever you want to hide or display data.