Home › Forums › Backend Issues (wp-admin) › How to populate Title from a different field › Reply To: How to populate Title from a different field
//add title and alias when a person is created
function my_acf_update_titlevalue( $value, $post_id, $field ) {
global $post;
// vars (title comes from person_name field that is looked for at the filter, after that the alias is generated)
$new_title = $value;
$new_slug = sanitize_title( $new_title );
// update post with the "new" title and alias (because we may hide them at our custom post)
$my_post = array('ID'=> $post_id,'post_title' => $new_title,'post_name' => $new_slug );
wp_update_post( $my_post );
return $value;
}
add_filter('acf/update_value/name=person_name', 'my_acf_update_titlevalue', 10, 3);
try something like above at your plugin: change person_name to your acf field
hope that help and work for you
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.