ACF 图像 returns 在 archive.php 中时不是 URL

ACF IMG returns ID not URL when in archive.php

我有一个 WordPress 网站,并且有一个简单的 div,在 footer.php 中有一个背景图片,从 ACF 选项字段调用,如下所示:

<div id="footer" style="background-image: url('<?php the_field('footer_background', 'options'); ?>');">

这适用于我所有的页面和模板。但是,当进入调用 archive.php 的博客类别(来自博客页面中的类别小部件)时,它将 URL 转换为图像 ID 并输出 '85' 而不是 URL.

我已经尝试从 archive.php 中删除所有代码,但页眉和页脚调用除外,以防万一我有一些东西在那里,但仍然没有运气。 ACF 字段肯定设置为 'url' 因此它在其他任何地方都有效。

知道为什么它会在 archive.php 页面上转换为 ID 吗?

我遇到了同样的问题,我没有找到插件的修复方法,但我通过条件语句检查页面是否为标签存档然后检索附件解决了这个问题 URL通过返回的 ID。

if (is_tag()) {
    $imgUrl = wp_get_attachment_url( get_field('image', 'option') );
    } else {
        $img = get_field('image', 'option');
        $imgUrl = $img['url'];
    }
}

我遇到了同样的问题。我的是因为我删除了一个旧字段并在另一个组中使用相同的名称重新创建了它。

发生的事情是旧的 ACF 密钥保持不变。这个非常 SO 的问题是 mentioned at ACF forum 我在其中找到了有关该问题的提示:

If an image field is always returning the image ID rather than another value as set in the field setting then this is a symptom of a missing or incorrect field_key in the database

我的旧存储值都是错误的,我不得不将它们更新为 field_60665667aa3d3 然后 URL return 又开始工作了。