Support

Account

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