【发布时间】:2015-09-27 21:08:20
【问题描述】:
我似乎无法只显示我请求的内容。我在我的 Wordpress 网站上使用Advanced Custom Fields (ACF) 插件,并使用带有“部门\职位”的多选字段的中继器字段。
使用下面的代码,我希望只显示值等于我选择的值的内容。也许我看错了,但内容显示 strpos 是否为真。
<?php if (get_field('policy_links') ): ?>
<center><h3><a name="All"></a>All Employees</h3></center>
<hr>
<ul class="bullets">
<?php while (has_sub_field('policy_links')) : ?>
<?php $jobtype = get_sub_field('who_is_this_for'); ?>
<?php if (strpos ($jobtype, 'ma') !== false) { ?>
<li><a href="<?php the_sub_field('link_to_the_document'); ?>">
<?php the_sub_field('display_name'); ?></a><span> - <small>
<?php the_sub_field('link_notes'); ?></small></span>
<?php the_sub_field('who_is_this_for'); ?></li>
<?php } else { ?><p>fail </p>
<?php }; // end of the loop. ?>
<?php endwhile; // end of the loop. ?>
</ul>
<?php endif; ?>
【问题讨论】:
-
请提供一个名字的例子,突出那些应该让你的
if声明是真的。
标签: php wordpress advanced-custom-fields