How to sync to custom taxonomies (tag structure)

I have two taxonomies: “Contributers” and “Narrators.”

I want to sync the terms in these two taxonomies identically, so much so that I wish to be able to click on “Edit Term” and see the information (Description, Title, slug, etc.) duplicated in the partnering taxonomy.

Read More

Right now, I have this (below) which does indeed insert the term with identical slug and even identical term_id (instead of appending the slug with a number), however the Description does not sync (as they are different term_taxonomy_id’s. All thoughts and suggestions are welcomed!

/**
 * Syncs the Contribute/Narrator Terms
 *
 * @param int $term_id
 * @param int $tt_id
 * @param string $taxonomy
 * @return string
 */
function lp_duplicate_created_terms( $term_id, $tt_id, $taxonomy ) {
    if ( $taxonomy != 'contributer' && $taxonomy != 'narrator' )
        return;

    static $count = 0;

    $term = get_term_by( 'id', $term_id, $taxonomy );

    $opposite = ( $taxonomy == 'contributer' ) ? 'narrator' : 'contributer';

    // Prevents function from running a second time in the following wp_insert_term
    if ( $count > 0 )
        $count = 0;
    else
        wp_insert_term( $term->name, $opposite, array( 'slug' => $term->slug, 'alias_of' => $term->slug, 'description' => $term->description ) );
    $count++;
}
add_action( "created_term", 'lp_duplicate_created_terms', 10, 3 );

Related posts