<?php if( get_field(\'packaging_details\',\'port\',\'lead_time\') ): ?>
<div class="prd-overview-list">
<h3>Packaging & Delivery</h3>
<ul>
<?php if( get_field(\'packaging_details\') ): ?><li><p>Packaging Details</p> <p><span><?php the_field( \'packaging_details\' ); ?></span></p></li><?php endif; ?>
<?php if( get_field(\'port\') ): ?><li><p>Port</p> <p><span><?php the_field( \'port\' ); ?></span></p></li><?php endif; ?>
<?php if( get_field(\'lead_time\') ): ?><li><p>Lead Time</p> <p><span><?php the_field( \'lead_time\' ); ?></span></p></li><?php endif; ?>
</ul>
</div><?php endif; ?>
如果所有3个字段都为空,请隐藏full div.如果任何字段有值,请显示full div
最合适的回答,由SO网友:Pratik Patel 整理而成
请尝试下面的内容,如果有任何疑问,请告诉我。
<?php if( get_field(\'packaging_details\') || get_field(\'port\') || get_field(\'lead_time\')): ?>
<div class="prd-overview-list">
<h3>Packaging & Delivery</h3>
<ul>
<?php if( get_field(\'packaging_details\') ): ?><li><p>Packaging Details</p> <p><span><?php the_field( \'packaging_details\' ); ?></span></p></li><?php endif; ?>
<?php if( get_field(\'port\') ): ?><li><p>Port</p> <p><span><?php the_field( \'port\' ); ?></span></p></li><?php endif; ?>
<?php if( get_field(\'lead_time\') ): ?><li><p>Lead Time</p> <p><span><?php the_field( \'lead_time\' ); ?></span></p></li><?php endif; ?>
</ul>
</div><?php endif; ?>
希望它能帮助你!