我在我的WordPress网站上使用高级自定义域,我在某些图像帖子类型的域中遇到了问题。
它们的输出如下:
<img src="57584, 57584, icon-star-green, icon-star-green.svg, 585, http://example.com/wp-content/uploads/2017/10/icon-star-green.svg, http://example.com/services/script-writing/icon-star-green/, , 1, , , icon-star-green, inherit, 58344, 2017-10-11 21:15:32, 2018-11-04 01:53:57, 0, image/svg+xml, image, svg+xml, http://example.com/wp-includes/images/media/default.png, 0, 0, Array" class="bens-item__icon" alt="">我已经尝试删除并重新创建自定义域,以及重新上传图标图像,结果相同。我还仔细检查了插件名称,一切看起来都很正常。
下面是代码调用此自定义字段的方式:
<img src="<?php the_field('industry_advantage1_icon'); ?>" class="bens-item__icon" alt="" />你知道为什么它会这样输出吗?我怎么解决它呢?
发布于 2019-10-28 22:18:59
acf字段返回一个数组。因此,要获取图像的url,首先将该字段赋给一个变量,如下所示:
$image = get_field('industry_advantage1_icon');然后您可以像这样调用这些值:
<img src="<?php echo $image['url'] ?>" class="bens-item__icon" alt="" />以下是有关如何使用高级自定义字段图像字段的文档。https://www.advancedcustomfields.com/resources/image/
https://stackoverflow.com/questions/58575928
复制相似问题