Support

Account

Home Forums ACF PRO No constant return value of get_field('image')

Solved

No constant return value of get_field('image')

  • Hi,

    I am using the image and gallery field for my custom post type, and now I am trying to display an image in my admin list.

    I added the columns and for the data/content of the field I am checking if there is an image set

    $image = get_field('image', $post_id);

    if not I am calling the gallery field and display the first image of the gallery array.

    The image field is set to return an object by the way.

    It works fine and I am able to display thumbnails for each post, until I filter the list.

    Then both the get_field('image') and get_field('gallery') return the image ID the first and an array with images IDs from the gallery the latter.

    Is this expected behavior?
    Is it related to the fact that my list query has been modified by filters?

  • Your filter is interfering with the query that ACF is doing to get the images. What are you using for the filter? Are you testing the query to make sure it the main query?

  • Are you testing the query to make sure it the main query?

    That was my mistake!
    Thanks @hube2

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘No constant return value of get_field('image')’ is closed to new replies.