Home › Forums › General Issues › Flexible content within repeater field
Hi
I’m having trouble with a nested loop. I have a repeater field with a flexible content field nested inside, but a can’t get it working.
My website loads everything that comes before this section, but not the section with the nested loop or anything that comes after. The section looks like this:
<div class="carousel-graphs-sm opacity-zero" style="margin-top: 0px;">
<?php
// check if the repeater field has rows of data
if( have_rows('slider_med_grafer') ) {
// loop through the rows of data
while ( have_rows('slider_med_grafer') ) : the_row();
?>
<div class="">
<div>
<div class="container-fluid">
<div class="row" style="margin-bottom: 50px;">
<?php
// check if the flexible content field has rows of data
if( have_rows('grafer') ) {
$countbar = 1;
$count = count( get_sub_field('grafer') );
if($count == 1 ) {
$col-md = 'col-md-4 col-md-offset-4';
} elseif( $count = 2 ) {
$col-md = 'col-md-4 col-md-offset-2';
} elseif( $count == 3) {
$col-md = 'col-md-4';
} elseif( $count == 4 ) {
$col-md = 'col-md-3';
};
// loop through the rows of data
while ( have_rows('grafer') ) : the_row();
if( get_row_layout() == 'barchart' ) {
?>
<div class="col-xs-12 <?php echo $col-md; ?>">
<div class="chart bar-<?php echo $countbar; ?>">
<?php
$procentikkeanbragt = get_sub_field('procentsats_ikke_anbragte');
$procentanbragt = get_sub_field('procentsats_anbragte');
if( $procentikkeanbragt > $procentanbragt ) {
$maxprocent = $procentikkeanbragt;
} else {
$maxprocent = $procentanbragt;
};
?>
<div class="bar-chart first" data-bars="[<?php the_sub_field('procentsats_ikke_anbragte'); ?>,<?php the_sub_field('procentsats_anbragte'); ?>]" data-max="<?php echo $maxprocent; ?>" data-unit="%" data-width="60">
<p class="bartext-left">
Ikke-anbragte
</p>
<p class="bartext-right">
Anbragte
</p>
<p class="bar-caption">
<?php the_sub_field('tekst'); ?>
</p>
</div>
</div>
</div>
<?php $countbar++; ?>
<?php
} elseif( get_row_layout() == "donutchart" ) {
?>
<?php
if( get_sub_field('procentsats') < 10 ) {
$procent = "0.0" . get_sub_field('procentsats');
} elseif( get_sub_field('procentsats') = 100 ) {
$procent = "1";
} else {
$procent = "0." . get_sub_field('procentsats');
};
?>
<div class="col-xs-12 <?php echo $col-md; ?>">
<div class="chart donut">
<div class="donut-chart fill uanimated" data-percent="<?php echo $procent; ?>" data-title="%">
<p class="circle-caption">
<?php the_sub_field('tekst'); ?>
</p>
</div>
</div>
</div>
<?php
} else {
// no layouts found
};
endwhile;
?>
</div>
<div class="row">
<div class="col-xs-12">
<p class="text-center kilde-tekst">
Kilde: <?php the_sub_field('kilde'); ?>
</p>
</div>
</div>
</div>
</div>
</div>
<?php
};
endwhile;
} else {
// no rows found
};
?>
</div>
You must be logged in to reply to this topic.
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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.