php - 使用带有特定 postID 的 get_field 返回空
问题描述
我试图在循环中使用 get_field 来检索一些自定义字段值,但是在使用 get_field('container', post_id) 时,该值始终为空。
我什至尝试在块文件中使用它,同样的情况发生了。
$container = get_field('container'); // this works
$test_container = get_field('container', 144); //this returns empty, post id === 144
解决方案
Did you try the_field() function.
In ACF the_field() function is used to display the value of a specific field. it is same as get_field(). https://www.advancedcustomfields.com/resources/the_field/
<?php if( get_field('container') ): ?>
<p><?php the_field('container', 144); ?> </p>
<?php endif; ?>
推荐阅读
- python - 没有在 Django Admin 中显示错误消息?
- datastage - 如果第一个作业活动中止,则中止第二个作业活动
- javascript - 如何使用javascript“重新提交”下拉选择?
- powershell - 使用通配符替换文件夹/文件
- r - add a dataframe column based on grouping by subtitles in R
- mixed-integer-programming - 整数规划:需要帮助来制定约束
- python - 熊猫选择每个月的最后一个星期五
- shell - 在托盘中启动时打开雷鸟
- c# - Devexpress 帮助创建此报告
- html - 在单个链接 ahref 链接中,如何在移动模式下控制此包装链接之间的间距?