Support

Account

Home Forums General Issues get_field() with Group field not working anymore

Solving

get_field() with Group field not working anymore

  • Hi folks,

    I’ve developed a Plugin long time ago. Now my client ask me to fix a bug. After some research I found the problem:
    The get_field() function is not working anymore with a Group field.

    
    global $post;
    $attributes = get_field('attributes', $post->ID);
    $price = get_field('price', $post->ID);
    $attributes_price = get_field('attributes_price', $post->ID);
    var_dump($attributes); 
    // bool(false) 
    var_dump($price);
    // NULL
    var_dump($attributes_price);
    // string(6) "103,00"
    

    I’ve also checked this behavior on another test site, but there get_field() on Group field returns an array of sub fields as it should.

    Any hint what is causing this issue?

    Thank you!

    Advanced Custom Fields PRO: 5.10.2
    WordPress: 5.8.1

  • Did you get to the bottom of this? I had a very similar problem on a website recently only it wasn’t limited to group fields. get_field was not working at all, even when explicitly passing in the post id, and I ended up falling back to using get_post_meta.

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

You must be logged in to reply to this topic.