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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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; ?>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0