I have the below code to update the WP core post title using an ACF field. This works with one post type, however I have multiple post types and need to do the same. How can I achieve that?
function acf_review_before_save_post($post_id) {
if (empty($_POST['acf']))
return;
$_POST['acf']['_post_title'] = $_POST['acf']['field_602ec4e591f90'];
return $post_id;
}
add_action('acf/pre_save_post', 'acf_review_before_save_post', -1);
@hube2 sorry I don’t understand how this relates to having more than one custom post type update the post title.
Using acf/pre_save post only works on front end forms, i does not work in the WP admin.
Setting the post title based on an ACF field is generally done using acf/save_post and does not involve altering $_POST['acf']['_post_title']
.
The older post I linked to explains how to do this using acf/save_post, which is what I would use.