Support

Account

Home Forums General Issues get_sub_field returning wrong field on ACF Pro 5.7.11

Solved

get_sub_field returning wrong field on ACF Pro 5.7.11

  • Hello

    I’ve got a repeater using the (admittedly badly named) sub fields ‘name’ and ‘text’ (the field ‘name’ being a text input, and ‘text’ being a textarea)

    If I use get_sub_field(‘text’) it is returning the content for the field ‘name’ under ACF Pro 5.7.11, but works correctly in 5.7.10.

    If I grab the contents of the parent repeater using get_field, I am able to iterate through this correctly using a foreach loop.

    As an example, let’s say that I populate the sub field ‘name’ with ‘John Smith’ and ‘text’ with some lorem ipsum

    This is returning John Smith:

    if( have_rows('portfolio') ):
    while ( have_rows('portfolio') ) : the_row();
    	the_sub_field('text');
    endwhile;
    endif;

    whereas this will correctly return the lorem ipsum:

    $repeater = get_field('portfolio');
    foreach($repeater as $pf) {
    	print_r($pf['text']);
    }

    Is this a bug, or should I just go ahead and rewrite it as a foreach?

    • canton

    • February 12, 2019 at 8:16 am

    I believe I’m experiencing a similar problem. Most of the images on our site broke after we upgraded to 5.7.11 because of this loop:

    while(have_rows('gallery')) : the_row();
     $image = get_sub_field('image');
     ...

    Whereas before $image contained the URL of our images, now $image is always just the letter ‘i’

    We’ve downgraded to an earlier version and hope that this is something that will get fixed with a point release…

  • Same issue here, it seems to be repeating the main field.
    downgrading to previous version fixes it.

    • Elliot

    • February 12, 2019 at 11:03 am

    Hi all.

    Thanks for the bug report. I’ll perform some testing and will report back shortly.

    • Elliot

    • February 12, 2019 at 11:13 am

    I’ve just spent some time testing a repeater field, but am unable to replicate the issues reported above. This leads me to suspect there is something else to the problem.

    Is it possible that your sites are using the register_field_group() function? We have been made aware of an issue regarding this function.

    If possible, can you please re-download the ACF PRO plugin files and test the issue?
    An easy way to re-download is to edit the main acf.php plugin file and change the version number ‘5.7.11’ down to ‘5.7.10’
    – please note the version number appears twice in this file and both will need to be changed
    – after this change is made, please update the plugin as per normal and it will update to 5.7.11 (including the new fix)

    • kjf

    • February 12, 2019 at 11:13 am

    Whatever bug is causing this for repeaters is probably also causing get_field_objects to not capture sub_fields of field type “group”. I just submitted a ticket about this with screenshots.

    • kjf

    • February 12, 2019 at 11:18 am

    Oh, I wasn’t running the latest version of PRO. Updating to 5.7.11 fixed my issue.

  • This reply has been marked as private.
    • Elliot

    • February 12, 2019 at 12:56 pm

    @johnnycomelately

    Thanks for the update. Can you please attach an export of your field group so that I can replicate the exact issue locally?

  • How do we send you the file? would prefer not to have it stored online.

    • Elliot

    • February 12, 2019 at 2:14 pm

    @johnnycomelately Please click the attachment icon (bottom left) of this comment box to display an attachment input.

    • Elliot

    • February 12, 2019 at 6:46 pm

    Hi all

    My apologies for the issues in version 5.7.11.
    I am confident we have found and fixed the issue.

    Can you please re-download the ACF PRO plugin files and test the issue?

    An easy way to re-download is to edit the main acf.php plugin file and change the version number ‘5.7.11’ down to ‘5.7.10’
    – please note the version number appears twice in this file and both will need to be changed
    – after this change is made, please update the plugin as per normal and it will update to 5.7.11 (including the new fix)

  • Seems to be working for me. Cheers.

  • Same here, working now – all good!

    • Elliot

    • February 13, 2019 at 10:21 am

    Thanks for the feedback. Glad to hear things are working again!

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.