how to hide empty fields of post category description?
-
22-04-2021 - |
Frage
I am creating one website from scratch, where I have to display Category description, how to hide the div, if there is no description written in backend for the post category?
my codes are:
<div class="row">
<div class="col-sm-8 mx-auto py-5">
<?php echo nl2br($qo->description) ?>
</div>
</div>
I want to hide the entire row, if there is no description written in backend for the post category.
Thanks.
Lösung
Wrap the div with a if condition like this. It should do the job!
<?php if($qo->description):?>
<div class="row">
<div class="col-sm-8 mx-auto py-5">
<?php echo nl2br($qo->description) ?>
</div>
</div>
<?php endif; ?>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit wordpress.stackexchange