get_term_meta

Home » Functions » get_term_meta

Function Name: get_term_meta

If you’re a WordPress developer, chances are you’ve come across the term "taxonomy" before. Taxonomies are ways to group things together, like categories and tags, and they’re an essential part of WordPress. With the get_term_meta function, you can retrieve metadata for a specific term within a taxonomy.

This function takes three parameters:

  1. $term_id – The ID of the term whose metadata you want to retrieve.
  2. $key – The name of the metadata you want to retrieve.
  3. $single – Whether to return a single value or an array of values. This parameter is optional and defaults to true.

Here’s an example of how you might use this function:

$term_id = 13; $key = ‘my_custom_key’; $single = true;

$meta_value = get_term_meta( $term_id, $key, $single );

This code retrieves the metadata with the key "my_custom_key" for the term with ID 13. If that metadata has multiple values, it will return only one value because $single is set to true. If $single was set to false, it would return an array of all the values.

Overall, get_term_meta is a useful function for retrieving metadata associated with a specific term in WordPress.

Learn More on WordPress.org

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