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

WP Hide parent container when both child fields (acf fields) are empty

需要一些帮助,因为我已经尝试了一些方法但没有成功...

我有一个容器 div,里面有两个字段 (wordpress acf)。如果它们有内容,我可以显示这些字段,如果它们是空的,它们就不会显示。我现在需要的是显示容器 div 如果一个或两个字段都有内容,或者如果两个字段都为空则隐藏容器字段。

当前代码

<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; ?>