add_action( 'save_post', 'func_update_rfg_titles', 99, 2 );
function func_update_rfg_titles( $post_id, $post ){
if ( 'tour' == $post->post_type ) {
$child_ids = toolset_get_related_posts(
$post_id,
'tour-guide-contact', // replace with your repeating field group slug
'parent',
999,
0,
array(),
'post_id',
'child'
);
if (!empty($child_ids) ){
foreach ( $child_ids as $child_id){
remove_action( 'save_post', 'func_update_rfg_titles', 99, 2 );
$title = get_post_meta($child_id,'wpcf-contact-name',true);
$title_update_args = array(
'ID' => $child_id,
'post_title' => $title
);
wp_update_post( $title_update_args );
add_action( 'save_post', 'func_update_rfg_titles', 99, 2 );
}
}
}
}
Where:
- Replace tour with your post type
- Replace "tour-guide-contact" with your original repeating field group name
- Replace slug wpcf-contact-name with your original Contact Name field slug if required