Home › Forums › Front-end Issues › How do you create post_title from another field(s) in ACF Pro? › Reply To: How do you create post_title from another field(s) in ACF Pro?
This works for me
add_action('acf/save_post', 'custom_acf_save_post', 20);
function custom_acf_save_post( $post_id ) {
// bail early if no ACF data
if( empty($_POST['acf']) ) {
return;
}
$data['ID'] = $post_id;
// Combine first name and last name to create a title
$title = trim($_POST['acf']['field_55687a737d49f']) . " " . trim($_POST['acf']['field_55687a917d4a0']);
$data['post_title'] = $title;
$data['post_name'] = sanitize_title( $title );
wp_update_post( $data );
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.