WordPress.org

Forums

[resolved] Assigning existing terms to taxonomy (3 posts)

  1. Mitchell Bundy
    Member
    Posted 3 years ago #

    Greetings!

    Is there any clean way to add an existing term, that is currently assigned to one taxonomy, to another taxonomy?

    Using wp_insert_term, it will add a new term no matter what. I don't want this to be an "alias" as I would like to keep the same term_id. Basically, all I would need is to put an entry into the wp_terms_taxonomy table, but you know, I'd like to avoid custom sql queries as much as I can.

    I am mapping users and photos to albums, and have two taxonomies, "album-user" and "album". Basically any user assigned to the term can post photos within that term.

    Thanks!

  2. Mitchell Bundy
    Member
    Posted 3 years ago #

    Figured out my own problem. But if anyone find it useful, you must specify the exact name and slug of the term in wp_insert_term as such:
    wp_insert_term($term->name, 'taxonomy', array('slug' => $term->slug));

    However, it would be nice to simply do this by id with a wp_assign_term

  3. Zlatev
    Member
    Posted 3 years ago #

    This should be documented! Thanks, exactly what I needed.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags