Support

Account

Home Forums General Issues getfield('gallery') is returning ids

Solved

getfield('gallery') is returning ids

  • Hi,

    (using ACF Pro Versión 5.3.1 and WP 4.3.1).

    I´ve a problem with get_field and a Gallery Field. Steps to reproduce it:

    -Fill a Gallery field using update_field( 'galeria', $ids_img_galeria,$post_id);

    Where ‘galeria’ is the name of the field and $ids_img_galeria is an array of attachments ids.

    -After doing that, i can see images properly on the field on the WP Admin.

    -Then if I use get_field(‘galeria’) to get all the images, i get something like:

    array (size=2)
      0 => int 1960
      1 => int 1961

    So, instead of an array with all images metadata i´m getting just the IDs os the images.

    If i manually save the post on the admin, get_field(‘galeria’) starts working properly.

    Thanks!

  • When updating a field that does not already have a value you need to use the field_key instead of the field value. There is more information on using field_keys in the documentation for update_field http://www.advancedcustomfields.com/resources/update_field/

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

The topic ‘getfield('gallery') is returning ids’ is closed to new replies.