Support

Account

Home Forums ACF PRO Custom field is not returned when calling get_fields

Solving

Custom field is not returned when calling get_fields

  • On my custom post type, I have a couple of custom group fields assigned to it.

    I am trying to get all the custom fields of a certain post of that type. I am calling it from another post.

    When calling get_fields($post_id), a specific custom field is not included with what the function returns.

    I am getting all the other custom fields, but there is one that is not included.
    That one is part of a group field that contains only 2 custom fields (destination and location_name).
    The array returned from the get_fields contains the destination, but not the location_name.

    If I call specifically that field with get_field('location_name', $post_id), I am getting the value of the field.

    What could be causing this?

  • I don’t know of anything that could cause this given what you’ve posted. The only time that get_fields() will not return a specific field is if the field name starts with an underscore (_).

    if you do this does the field appear in the returned array?

    
    $fields = get_fields($post_id);
    echo '<pre>'; print_r($fields); echo '</pre>';
    
  • Happy New Year John!

    What you asked me to try is what the issue is. So the answer is no, that field is not contained in the returned array.

    Anyway, that’s a finished project by now and given the issue, I just went by getting that specific field individually.
    For the time being, I am not going to dig it further.

    Thanks a lot for your response!

    @hube2

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

You must be logged in to reply to this topic.