Hello i would like to auto complete the title of a post.
function add_custom_title( $data, $postarr ) {
$my_post_id = $postarr['ID'];
if($data['post_type'] == 'menu-resto-scolaire') {
$semaine=get_field('semaine', $my_post_id);
$data['post_title'] = 'Semaine :' . $semaine;
}
return $data;
}
add_filter('wp_insert_post_data', 'add_custom_title', 10, 2 );
post_title is always : “Semaine :’
Have you an idea to help me ?
Sorry for my english
Thanks a lot my friend
i found this code with your help : https://support.advancedcustomfields.com/forums/topic/using-acf_form-add-post-title/
It’ works like a charm :p