0

有没有办法可以检查

<?php the_field('max_working_height')?> 

是空的,或者存储我使用acnd时将显示的值,检查它是否为空。如果该值不为空,那么我必须让它像这样执行一组 html 代码和 php 代码

    <tr style="height: 25px; margin-left: 10px;">
<td style="margin-left: 10px;"><b>Max
  <?php the_field('max._outreach'); ?></td> 
</tr>

请帮忙。

4

2 回答 2

0

如果您使用的是 ACF 插件,则the_field()显示该字段的值。如果要捕获字段的值,请使用get_field(). 在这里查看文档。

于 2013-02-08T13:57:38.150 回答
0
<?php
$maxWorkingHeight = the_field('max_working_height');

if (false == $maxWorkingHeight) {
    // print your html/php
} else {
    // you can print $maxWorkingHeight here if you need it
}

这假定如果未设置该字段,您的函数将返回一个虚假值(nullfalse0或空字符串都是 PHP 中虚假值的示例)。

于 2013-02-08T13:51:55.813 回答