Home » Functions » update_term_meta

WordPress comes with a lot of built-in functions that allow developers to easily create custom applications and features. One such function is update_term_meta.

Update_term_meta is a function that allows you to update the metadata of a term in WordPress. A term can be a category, tag, or any other custom taxonomy you have created. Metadata is additional information about a term that you can store in the database. This can include things like descriptions, images, or any other custom data you want to associate with a term.

The update_term_meta function takes three parameters: $term_id (the ID of the term you want to update), $meta_key (the name of the metadata you want to update), and $meta_value (the new value for the metadata). If the metadata does not already exist for the term, it will be created.

Here’s an example usage code:

// Update the description for the "Recipes" category
$term_id = 5;
$meta_key = 'description';
$meta_value = 'Browse our collection of delicious recipes!';
update_term_meta($term_id, $meta_key, $meta_value);

In this example, we are updating the description metadata of the "Recipes" category. The term ID for the category is 5, and the metadata key is "description". We are setting the new value for the metadata to "Browse our collection of delicious recipes!".

Overall, update_term_meta is a useful function for customizing the metadata of your terms in WordPress.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.