Support

Account

Home Forums Bug Reports Content dissapears on update

Solved

Content dissapears on update

  • Strange problem – I’ve created a content management system for a site using ACF. The default classic editor works OK but when I use any of my fields the changes are dissapearing on save.

    So I create content, preview them – all looks good. Go back to edit and the content has dissapeared from the backed. If I hit update it will override the content and wipe it out.

    It’s a multisite install.

  • I get this issue now and again and usually comes from conflicting naming convention on your fields or if you have some field groups registered in both json and in the DB that are sharing field keys for some reason (human error)

  • 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;
    
    }
    
    ?>
  • Since you are using the layout custom field, you should probably also take a look at this post…

    php-input-variables-exceeded-1000

    On complex field groups it is possible for the number of form variables submitted to exceed your web server’s maximum number of allowed variables per post. This happened to me on what seemed like a field group that wasn’t all that big. But once you start repeating layouts, the number of inputs can become quite large.

    Until the developers start using a different method of saving data (like I suggested in my post) you will either have to change the configuration of your web server (not always possible on shared web hosting) or figure out a different way to do it.

  • Thanks @wp_kc – it appears to be fixed by increasing the max_input_vars to 2000

  • Ah – spoke to soon, the first time it worked but the next time it reoccured.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Content dissapears on update’ is closed to new replies.