Home › Forums › Bug Reports › Content dissapears on update › Reply To: Content dissapears on update
Thanks @magicstick
I suspect my naming conventions are conflicting – should the variable be different for each subfield or does the subfield name itself need to be different.
I think I’m dreading the answer…
<?php
if ( ! post_password_required() ) {
// check if the flexible content field has rows of data
if( have_rows('page_content') ):
// loop through the rows of data
while ( have_rows('page_content') ) : the_row();
//100% row, no padding, for slider
if( get_row_layout() == 'fullwidth' ):
// check if the nested repeater field has rows of data
if( have_rows('fullwidth') ):
// loop through the rows of data
while ( have_rows('fullwidth') ) : the_row();
$content = get_sub_field('content');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<?php echo $content; ?>
</div>
<?php endwhile;
endif;
endif; //END Single Row
//Row with no padding
if( get_row_layout() == 'nopad' ):
// check if the nested repeater field has rows of data
if( have_rows('nopad') ):
// loop through the rows of data
while ( have_rows('nopad') ) : the_row();
$content = get_sub_field('content');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container">
<div class="padme">
<?php echo $content; ?>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END Single Row
//SINGLE ROW
if( get_row_layout() == 'single_row' ):
// check if the nested repeater field has rows of data
if( have_rows('single_row') ):
// loop through the rows of data
while ( have_rows('single_row') ) : the_row();
$content = get_sub_field('content');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container padout">
<div class="padme">
<?php echo $content; ?>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END Single Row
//SINGLE ROW contained
if( get_row_layout() == 'single_row_small' ):
// check if the nested repeater field has rows of data
if( have_rows('single_row_small') ):
// loop through the rows of data
while ( have_rows('single_row_small') ) : the_row();
$content = get_sub_field('content');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container-sm padout">
<div class="padme">
<?php echo $content; ?>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END Single Small
// check current row layout
if( get_row_layout() == '2_columns_5050' ):
// check if the nested repeater field has rows of data
if( have_rows('2_columns_5050') ):
// loop through the rows of data
while ( have_rows('2_columns_5050') ) : the_row();
$left = get_sub_field('column_left_50');
$right = get_sub_field('column_right_50');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container padout">
<div class="col-md-6 center-block padme">
<?php echo $left; ?>
</div>
<div class="col-md-6 center-block padme">
<?php echo $right; ?>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END 2 columns 5050
// check current row layout
if( get_row_layout() == '2_columns_7030' ):
// check if the nested repeater field has rows of data
if( have_rows('2_columns_7030') ):
// loop through the rows of data
while ( have_rows('2_columns_7030') ) : the_row();
$title = get_sub_field('title');
$left = get_sub_field('column_left_70');
$right = get_sub_field('column_right_30');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container padout">
<h2 class="text-center"><?php echo $title; ?></h2>
<div class="col-md-9 padme">
<?php echo $left; ?>
</div>
<div class="col-md-3 padme">
<?php echo $right; ?>
</div>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END 2 columns 7030
// check current row layout
if( get_row_layout() == '3_columns' ):
// check if the nested repeater field has rows of data
if( have_rows('3_columns') ):
// loop through the rows of data
while ( have_rows('3_columns') ) : the_row();
$title = get_sub_field('title');
$left = get_sub_field('column_left');
$middle = get_sub_field('column_middle');
$right = get_sub_field('column_right');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container padout">
<h2 class="text-center"><?php echo $title; ?></h2>
<div class="col-md-4 padme center-block">
<?php echo $left; ?>
</div>
<div class="col-md-4 padme center-block">
<?php echo $middle; ?>
</div>
<div class="col-md-4 padme center-block">
<?php echo $right; ?>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END 3 columns
// check current row layout
if( get_row_layout() == '4_columns' ):
// check if the nested repeater field has rows of data
if( have_rows('4_columns') ):
// loop through the rows of data
while ( have_rows('4_columns') ) : the_row();
$title = get_sub_field('title');
$col1 = get_sub_field('column_1');
$col2 = get_sub_field('column_2');
$col3 = get_sub_field('column_3');
$col4 = get_sub_field('column_4');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container padout">
<h2 class="text-center"><?php echo $title; ?></h2>
<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
<?php echo $col1; ?>
</div>
<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
<?php echo $col2; ?>
</div>
<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
<?php echo $col3; ?>
</div>
<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
<?php echo $col4; ?>
</div>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END 4 columns
// check current row layout
if( get_row_layout() == 'background_image' ):
// check if the nested repeater field has rows of data
if( have_rows('background_image') ):
// loop through the rows of data
while ( have_rows('background_image') ) : the_row();
$bgimage = get_sub_field('image');
$caption = get_sub_field('caption'); ?>
<div class="clearfix">
<div class="parallax-sm" data-bs-parallax-bg="true" style="background-image:url(<?php echo($bgimage); ?>);">
<h2 class="title text-center"><?php echo $caption; ?></h2>
</div>
</div>
<?php endwhile;
endif;
endif; //END 2 columns 7030
// check current row layout
if( get_row_layout() == 'youtube_video' ):
// check if the nested repeater field has rows of data
if( have_rows('youtube_video') ):
// loop through the rows of data
while ( have_rows('youtube_video') ) : the_row();
$embedlink = get_sub_field('embed_link');
$info = get_sub_field('info');
$colour = get_sub_field('background_colour'); ?>
<div class="clearfix <?php echo $colour; ?>">
<div class="container">
<?php echo $info; ?>
<div class='embed-container'>
<iframe src='https://www.youtube.com/embed/<?php echo $embedlink; ?>' frameborder='0' allowfullscreen></iframe>
</div>
</div>
</div>
<?php endwhile;
endif;
endif; //END YouTube
endwhile;
else :
// no layouts found
endif;
}
?>
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.