Convert Custom Post Types to Custom Taxonomies

Here’s the solution that worked for me. I added the below code to a page template (page-test.php) and then created a page called “test,” loaded the page, and all the CPTS were converted to taxonomies. Not sure if this happened when I created the page or when I loaded it… And then I quickly deleted the page template so I didn’t end up with a bunch of duplicates.

<?php
    function cpt_to_tax($post_type, $taxonomy) {
    $posts = get_posts(array(
                 'post_type' => $post_type,
                 'posts_per_page' => -1,
            ));
    
    foreach($posts as $post) {
        wp_insert_term($post->post_title, $taxonomy, array(
                'description' => $post->post_content,
            ));
        }
    }

    cpt_to_tax('jjm_authors', 'jjm_author_tax');
?>

The solution itself was provide by https://wordpress.stackexchange.com/users/35470/circuuz, though his post seems to be deleted now. 🙁