Home › Forums › Backend Issues (wp-admin) › Auto populate post title with ACF Taxonomy Field › Reply To: Auto populate post title with ACF Taxonomy Field
Hi @kikadesign
For single value Taxonomy selection, you can set the return type to “Term Object” and then make use of this code:
function create_title( $post_id ) {
// Set variables
$term = get_field( 'ministry_name', $post_id );
$name = $term->name;
// Set post title and permalink
$post_title = $name;
// update the post, which calls save_post again
wp_update_post( array(
'ID' => $post_id,
'post_title' => $post_title,
'post_name' => $post_name,
)
);
}
add_action( 'acf/save_post', 'create_title', 20 );
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.