Content Insert


add_action('acf/save_post', 'my_acf_save_post');
function my_acf_save_post( $post_id ) {
	$this_post = get_post($post_id);
	if($this_post->post_type != "resources") { return; }
    
    $all_rows = "";
    for ($x = 1; $x <= 4; $x++) {
	    if( have_rows('cell_'.$x, $post_id) ) { $count = 0; while ( have_rows('cell_'.$x, $post_id) ) { the_row(); 
			    $cell_text        = get_sub_field('cell_text'); 
	            $file             = get_sub_field('file_'.$x);  //var_dump($file["filename"]); exit; 
	            if(!empty($file)) {
	                $filename         = "File: ".$file["filename"];
	                $fileurl          = $file["url"];
	            }else { $filename = ""; $fileurl = ""; }
	            $alternate_link   = get_sub_field('alternate_link');
	            $all_rows .= "$cell_text  $filename $fileurl $alternate_link <br />";
	    } } 
    }
	$my_post = array(
	    'ID'             => $post_id,
	    'post_content'   => $all_rows,
	);
	wp_update_post( $my_post );
	
}
Comments