Home Forums General Issues get_fields(); returning an empty Array()


get_fields(); returning an empty Array()

  • Hi all,

    I’ve been using get_fields() in a theme to get all the custom fields that are connected to a post.

    This works when I’m in 4.x but since I updated to 5.x PRO this isn’t working anymore.

    Strangely, when i use get_field('name', post_id) I can get all the values. They also show up in the admin area.

    Any ideas? I’ve been looking into it for a while and cannot figure it out.

    Thanks in advance,

  • I have the same problem with get_fields(). Can’t get the fields in my html.

    array(1) { [0]=> array(4) { [“acf_fc_layout”]=> string(5) “panel” [“panel_header”]=> string(2) “dd” [“panel”]=> array(1) { [0]=> array(3) { [“panel_title”]=> string(16) “Titulo del panel” [“panel_content”]=> string(19) “Contenido del panel” [“img”]=> string(56) “http://t0t-2.local:5757/wp-content/uploads/cirerers.jpg” } } [“panel_footer”]=> string(2) “dd” } }

  • Hi @dennisp93 and @sergi0fores

    If by adding the post id as the second parameter the method works, then the problem is related to the post id.

    It is possible that the current post id does not reflect the posts that have the custom field.

    You could try <?php $postid = get_the_ID(); echo $postid; ?>to see the current loaded post id.

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

The topic ‘get_fields(); returning an empty Array()’ is closed to new replies.