Support

Account

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 );