【问题标题】:Hide ACF Field When Two Other Fields are Empty当其他两个字段为空时隐藏 ACF 字段
【发布时间】:2019-10-03 13:26:23
【问题描述】:

在我的页面上,我有一份作为 CPT 的工作人员名单。他们中的一些人有额外的认证和/或生物。

我如何才能包含“阅读更多”链接,但如果认证字段或生物字段有内容?

【问题讨论】:

    标签: php wordpress advanced-custom-fields


    【解决方案1】:

    你可以做这样的事情。如果您正在寻找或正如您所提到的,您只需检查认证字段,如果它有值,您将显示链接。如果它不检查生物领域。有价值展示链接。

    <?php
    
    $certs = get_field( "cert_field" ); // add field name here for certifications
    $bio = get_field( "bio_field" ); // add field name here for bio
    
    <?php if($certs) : ?> <!-- Check if cert field has value -->
    
        <a href="#">Read More</a> <!-- If true it will show read more -->
    
    <?php else if($bio) : ?> // Else check for bio field
    
        <a href="#">Read More</a> <!-- If true it will show read more -->
    
    <?php endif; ?>
    

    【讨论】:

      猜你喜欢
      • 2018-06-18
      • 1970-01-01
      • 2019-07-23
      • 2013-10-02
      • 2013-09-03
      • 1970-01-01
      • 2014-05-15
      • 2018-11-29
      • 2018-04-30
      相关资源
      最近更新 更多