I’m trying to automatically copy content from ACF field to standard post_content. I’ve created something like this:
function acf_copy() {
$acf = get_sub_field('regular_content');
$post = get_post();
$my_post = array(
'ID' => $post->ID,
'post_content' => $acf
);
wp_update_post($my_post);
}
add_action( 'save_post', 'acf_copy', 10, 2 );
but it’s returns error… Can someone help me to improve / repair this code? 🙂
//thanks
Hi @damian-p
The first thing that you need to note is that you cannot call the get_sub_field() without making use of the have_rows() function. This function is vital to step through all the rows of repeater. You can then grab the value of each row and save them to an array. Please take a look at the Repeater resource page for more info on this.