Copy/Move selected taxonomy terms to another taxonomy for posts

I’ve been searching for about 2 hours now on a solution of copying/moving selected taxonomy values for each posts to another. Here’s the situation.

I’m working on a site that has a post type of articles and I’m moving them back to the innate post post type. Within the articles, I’ve had a taxonomy that was for the categories and I’ve successfully moved over the terms to the default categories taxonomy for the post type.

Now, I’m ready to bulk convert the posts (articles -> post) which isn’t a problem. But I need to have the selected terms that were checked in the old category taxonomy also checked/marked in the new one.

Is there any way to achieve this in a bulk fashion. I don’t want my clients to have to go through every individual post and remark their category terms.

Thank you in advance!

Solutions Collecting From Web of "Copy/Move selected taxonomy terms to another taxonomy for posts"

This will get all posts with $old_tax, copy the terms from $old_tax to $new_tax, and then set the $new_tax terms for those posts.

    function convert_tax($old_tax, $new_tax) {
        $pages = get_posts(array(
            'post_type' => 'post',
            'posts_per_page' => -1,
            'tax_query' => array(
                    'taxonomy' => $old_tax,
                    'operator' => 'EXISTS'

        foreach($pages as $post) {
            $terms = get_the_terms( $post->ID, $old_tax );
            $term = array();

            foreach( $terms as $t ) {
                if( get_term_by( 'name', $t->name, $new_tax ) == false ) {
                    wp_insert_term( $t->name, $new_tax, $args = array() );
                    wp_set_post_terms($post->ID, array(intval($t->ID)), $new_tax ); 

    convert_tax('policy_area', 'topic')


as long as the slugs from your articles taxonomy map exactly to the slugs in your default category you should be able to do something like this for each article:

        $article_cats = wp_get_object_terms( $article_id, 'article-category' );
        $new_cats = array();
        foreach( $article_cats AS $t ) {
            $new_cats[] = $t->slug;
        wp_set_object_terms( $post_id, $new_cats, 'categories' );