Title: Term meta data deleted when using wp_update_term
Last modified: December 25, 2020

---

# Term meta data deleted when using wp_update_term

 *  [Kai](https://wordpress.org/support/users/kaiono/)
 * (@kaiono)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/term-meta-data-deleted-when-using-wp_update_term/)
 * I am trying to update my term description using the wp_update_term function.
   
   When I run the code below, the meta data registered in the same term dissappears.
 *     ```
       $term_args = [
        'description' => 'text'
       ];
       $update_term = wp_update_term( $term_id, 'custom-term', $term_args );
       ```
   
 * Do I have to get the meta data before this and register it after wp_update_term
   every time, or is there a way to avoid this?
    Thank you
    -  This topic was modified 5 years, 4 months ago by [Kai](https://wordpress.org/support/users/kaiono/).
    -  This topic was modified 5 years, 4 months ago by [Kai](https://wordpress.org/support/users/kaiono/).
    -  This topic was modified 5 years, 4 months ago by [Kai](https://wordpress.org/support/users/kaiono/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Olga Gleckler](https://wordpress.org/support/users/oglekler/)
 * (@oglekler)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/term-meta-data-deleted-when-using-wp_update_term/#post-13832929)
 * Are you sure that you are not mixing a taxonomy and the term slug?
 *  Thread Starter [Kai](https://wordpress.org/support/users/kaiono/)
 * (@kaiono)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/term-meta-data-deleted-when-using-wp_update_term/#post-13832982)
 * Thank you. I double checked again but the slug was not mixed up.
    I found out
   that the meta data dissapears when I saved an array object inside.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/term-meta-data-deleted-when-using-wp_update_term/#post-13835066)
 * wp_update_term() doesn’t impact term meta one way or another on its own. However,
   to save term meta data, we typically hook into one of the function’s actions.
   I think the problem is in whatever logic is used to save term meta on creation.
   It’s not differentiating between a new insertion and an update. With an update,
   there’s no meta data, so what had been saved is replaced by empty data. So either
   alter that logic, or you will need to fetch the existing data before updating.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Term meta data deleted when using wp_update_term’ is closed to new replies.

## Tags

 * [metadata](https://wordpress.org/support/topic-tag/metadata/)
 * [term](https://wordpress.org/support/topic-tag/term/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/term-meta-data-deleted-when-using-wp_update_term/#post-13835066)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
