Home Forums ACF PRO Problem retrieving image object from a specific page ID


Problem retrieving image object from a specific page ID

  • Hi all,

    So here’s the situation. I’m loading a few fields from a specific page, while on the index.php template.

    $img = get_field('background', 30);

    The text fields show up fine no matter what, but if the index.php template is delivering a Category or Tag archive, the image field doesn’t return the expected image object.

    Any ideas why get_field() works inconsistently in this case?


    I discovered that in the case of a Category or Tag archive, the ACF returns the image ID, even if “Image Object” is the desired output.

    I’m guessing this is a bug?

  • Hi @dkeeling

    Thank you for pointing this out.

    Possibly, could be a bug, can’t seem to replicate it though.

    What steps do I need to take in order to replicate this?

  • @acf-support

    Hi James,

    Basically, you’ll just need to add an image field to any given page, and choose “Image Array” as the output.

    Then, in index.php, try to pull in the image object into a variable, passing the ID of the page you’ve chosen as the second parameter.

    You should find that it works inconsistently — sometimes returning just the image ID rather than the object.

    Here’s a link to a video that shows my particular situation… probably about as clear as mud. 🙂

    If you need further detail or code, just let me know.


  • Hi @dkeeling

    Thank you for clarifying more on this.

    Passing this to the developer so that he can investigate more.


  • Hey @acf-support James,

    Just wanted to check in on the status of this. I’ve found another instance where this is happening now — when trying to retrieve an ACF taxonomy image from on the taxonomy page (taxonomy.php).

    I can pull them in fine from other pages, but when on taxonomy.php get_field() returns the image ID rather than the array.

  • Hi @dkeeling,

    The inconsistent results from the get_field() when getting values from a static page should now be fixed 🙂

    I have tested this on the latest version

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

The topic ‘Problem retrieving image object from a specific page ID’ is closed to new replies.