Support

Account

Home Forums Add-ons Flexible Content Field How to get Group fields from within a Flexible Content field Reply To: How to get Group fields from within a Flexible Content field

  • You need to get the field “section_settings” and then get the sub field “top_and_bottom_padding” from that. This can be done in a few ways.

    
    // get sections settings as an array
    $section_settings = get_sub_field('section_settings');
    $sectionPadding = $section_settings['top_and_bottom_padding'];
    
    // loop group field
    if (have_rows('section_settings')) {
      // always true for group field
      while (have_rows('section_settings')) {
        // always happens one time for group field
        the_row();
        $sectionPadding = get_sub_field('top_and_bottom_padding');
      }
    }
    
    // get field directly
    // to be honest, I don't know if this will work with nested fields
    // format here is "{$parent_field_name}_{$child_field_name}"
    $sectionPadding = get_sub_field('section_settings_top_and_bottom_padding');