I have a WordPress site and have a simple div with a background image in footer.php
being called from ACF options field like so:
<div id="footer" style="background-image: url('<?php the_field('footer_background', 'options'); ?>');">
This works perfectly on all my pages and templates. However, when going into a blog category (from the categories widget in the blog page) which is calling archive.php
it converts the URL to the image ID and outputs '85'
rather than the URL.
I've tried removing all code from archive.php except the header and footer calls incase I had something in there but still no luck. The ACF field is definitely set to 'url' hence it works everywhere else.
Any ideas why it converts to ID on the archive.php
page?
I was having the same problem, and I found no fix for the plugin, but I solved the situation by making a conditional statement to check if the page was a tag archive and then retrieve the attachment URL by the returned ID.
if (is_tag()) {
$imgUrl = wp_get_attachment_url( get_field('image', 'option') );
} else {
$img = get_field('image', 'option');
$imgUrl = $img['url'];
}
}