WordPress: 4.9
ACF Pro: 5.6.5
Hi,
is there any bug with using fields in group layout on option page?
I´ve got an options page in a custom post type. Getting a single option field works fine, but I am not able to get the values from inside a group layout. When visiting the options page with get_field('my_group_layout' , 'option');
somewhere in my plugin, the group layout is gone.
Thanks for any help.
A group field works like a repeater. You either need get the parent field as an array or treat it as a repeater field with 1 row. You cannot use get_field() to get the value of a sub field of the group. https://www.advancedcustomfields.com/resources/group/
Late reply, but maybe this will help other people:
Instead of struggling with have_rows, do a foreach
<?php
$group = get_field('groupname');
$repeater = $group['repeatername'];
foreach($repeater as $value){
//inside loop / repeater
echo $value['fieldname']; // the field name you desire
}
?>
I’ve learned since my original post that you can get a sub field of a group field without a loop.
get_field('[GROUP FIELD NAME]_[SUB FIELD NAME]');