【发布时间】:2019-10-03 13:26:23
【问题描述】:
在我的页面上,我有一份作为 CPT 的工作人员名单。他们中的一些人有额外的认证和/或生物。
我如何才能包含“阅读更多”链接,但仅如果认证字段或生物字段有内容?
【问题讨论】:
标签: php wordpress advanced-custom-fields
在我的页面上,我有一份作为 CPT 的工作人员名单。他们中的一些人有额外的认证和/或生物。
我如何才能包含“阅读更多”链接,但仅如果认证字段或生物字段有内容?
【问题讨论】:
标签: php wordpress advanced-custom-fields
你可以做这样的事情。如果您正在寻找或正如您所提到的,您只需检查认证字段,如果它有值,您将显示链接。如果它不检查生物领域。有价值展示链接。
<?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; ?>
【讨论】: