Home › Forums › ACF PRO › Image field returns a string instead of an array › Reply To: Image field returns a string instead of an array
hi John, thanks for answering.
I have a template part named ‘loop.php’, which I use to display all loops in my application.
In this file I use the following code to display image from custom field:
<?php
$image = get_field('event_cover');
if( !empty($image) ):
?>
<img src="<?php echo $image['sizes']['medium'] ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
$image
gets an array of values (as expected) in all pages, but not in search results page if posts are filtered by distance… it gets a string value instead.
Not sure if I’m clear… sorry
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.