-1

divの前に変数値をチェックして、変数が空の場合はif条件にあるdivを非表示にし、その逆も同様にします。

例えば:

<?php $var=has_post_thumbnail();
if(!empty($var)){ ?>
<div>//some code that is shown only if var has some value</div>
<?php } ?>
4

1 に答える 1

0
<?php if(isset($var)) // or check for empty if you want that way{ ?>
    <div> yes variable is set </div>
<?php } else { ?>
    <div> variable not set division </div>
<?php } ?>
于 2012-09-12T08:00:43.983 に答える