【发布时间】:2016-09-07 15:46:21
【问题描述】:
我正在使用Advanced Custom Fields PRO Version 5.3.7。我正在尝试加载我的自定义帖子类型中的图片。
我已经为自定义帖子类型配置了 ACF 字段,它适用于文本相关字段。
但是,我正在尝试显示图像。我正在使用来自acf documentation 的改编示例。您可以在下面找到我的代码。
<div class="image">
<a href="<?php the_field('link'); ?>" rel="nofollow" class="am" target="_blank" > <img class="b-lazy wp-post-image b-loaded" alt="<?php echo the_field('box_image')['alt']; ?>" src="<?php echo the_field('box_image')['url']; ?>" width="230"> </a>
</div>
我的问题是,在我的网站上,我得到的是数组而不是单个值:
任何建议我的代码有什么问题?
感谢您的回复!
【问题讨论】:
-
$image = get_field('image');并检查echo "<pre/>";print_r($image);的输出结果,然后我们将为您提供帮助
标签: php wordpress advanced-custom-fields custom-fields