Php 当两个子字段(acf字段)都为空时隐藏父容器

Php 当两个子字段(acf字段)都为空时隐藏父容器,php,wordpress,advanced-custom-fields,Php,Wordpress,Advanced Custom Fields,我可以帮点忙,因为我尝试了一些事情,但没有运气 我有一个容器div,其中有两个字段(wordpress acf)。如果字段有内容,我可以显示字段;如果字段为空,我可以不显示字段。我现在需要的是,如果一个或两个字段都有内容,则显示container div;如果两个字段都为空,则隐藏container字段 现行代码 <div class="header-contact"> <?php if( get_field('header_tel', 'option') ): ?&g

我可以帮点忙,因为我尝试了一些事情,但没有运气

我有一个容器div,其中有两个字段(wordpress acf)。如果字段有内容,我可以显示字段;如果字段为空,我可以不显示字段。我现在需要的是,如果一个或两个字段都有内容,则显示container div;如果两个字段都为空,则隐藏container字段

现行代码

<div class="header-contact">    
<?php if( get_field('header_tel', 'option') ): ?>

                        <p>Tel No: <a href="tel:<?php the_field('header_tel', 'option'); ?>"><?php the_field('header_tel', 'option'); ?></a></p>

                    <?php endif; ?>

                    <?php if( get_field('header_email', 'option') ): ?>
                    <a href="mailto:<?php the_field('header_email', 'option'); ?>"><?php the_field('header_email', 'option'); ?></a>
                    <?php endif; ?>
</div>

电话:

任何帮助都很好…

可能的解决方案:

<?php if( get_field('header_tel', 'option') || get_field('header_email', 'option') ): ?>
   <div class="header-contact"> 
     <?php if( get_field('header_tel', 'option') ): ?>
       <p>Tel No: <a href="tel:<?php the_field('header_tel', 'option'); ?>"><?php the_field('header_tel', 'option'); ?></a></p>
     <?php endif; ?>
     <?php if( get_field('header_email', 'option') ): ?>
       <a href="mailto:<?php the_field('header_email', 'option'); ?>"><?php the_field('header_email', 'option'); ?></a>
     <?php endif; ?>
   </div>
<?php endif; ?>

电话:

可能的解决方案:

<?php if( get_field('header_tel', 'option') || get_field('header_email', 'option') ): ?>
   <div class="header-contact"> 
     <?php if( get_field('header_tel', 'option') ): ?>
       <p>Tel No: <a href="tel:<?php the_field('header_tel', 'option'); ?>"><?php the_field('header_tel', 'option'); ?></a></p>
     <?php endif; ?>
     <?php if( get_field('header_email', 'option') ): ?>
       <a href="mailto:<?php the_field('header_email', 'option'); ?>"><?php the_field('header_email', 'option'); ?></a>
     <?php endif; ?>
   </div>
<?php endif; ?>

电话:


实际问题是什么?您不知道有哪些逻辑运算符,或者什么?(顺便说一句,由于要多次调用这些函数,所以应该将结果存储在变量中。)基本上,我不知道该怎么做。感谢您提供有关变量的提示以及实际问题是什么-您不知道有哪些逻辑运算符,或者什么?(顺便说一句,由于要多次调用这些函数,所以应该将结果存储在变量中。)基本上,我不知道该怎么做。感谢您提供有关变量的提示