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');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.