Home › Forums › Add-ons › Repeater Field › Flexible Content & Repeater Content Showing
Okay, I have a flexible content container inside a repeater field. I have the flexible content showing alright. However, is there any way that I can get the other fields within the repeater field to show? Other than those inside the flexible content.
Here’s what I’m using:
<?php
if (have_rows('home_points')) {
while (have_rows('home_points')) {
the_row();
if (have_rows('point_column')) {
while (have_rows('point_column')) {
the_row();
$layout = get_row_layout();
if ($layout == 'column_header') {
the_sub_field('column_head');
} elseif ($layout == 'column_row') {
the_sub_field('another_row');
}
the_sub_field('brand_1'); //this is the repeater subfield I want to show
}
}
//I also tried putting the repeater subfield here.
}
}
?>
You can’t get values from the repeater inside of the loop for the nested repeater.
the_row() will actually return an array of the current row
<?php
if (have_rows('home_points')) {
while (have_rows('home_points')) {
// this will return the current repeater row in an array
$repeater_row = the_row();
// any call to the_sub_field() or get_sub_field()
// here should get sub fields of the repeater "home_points"
if (have_rows('point_column')) {
while (have_rows('point_column')) {
the_row();
// you cannot get fields from the repeater inside of the
// loop that is getting values from the nested repeater
$layout = get_row_layout();
if ($layout == 'column_header') {
the_sub_field('column_head');
} elseif ($layout == 'column_row') {
the_sub_field('another_row');
}
// use the array $repeater_row to access parent repeater row values
echo $repeater_row['brand_1'];
}
}
// any call to the_sub_field() or get_sub_field()
// here should get subfields of the repeater "home_points"
}
}
?>
The topic ‘Flexible Content & Repeater Content Showing’ is closed to new replies.
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.