Glossary Term
wp_insert_term()
wp_insert_term() — Adds a new term to the database. A non-existent term is inserted in the following sequence: 1. The term is added to the term table, then related to the taxonomy. 2. If everything is correct, several actions are fired. 3. The ‘term_id_filter’ is evaluated. 4. The term cache is cleaned. 5. Several more actions are fired. 6. An array is returned containing the term_id and term_taxonomy_id. If the ‘slug’ argument is not empty, then it is checked to see if the term is invalid. If it is not a valid, existing term, it is added and the term_id is given.
Inputs: $term (string): The term name to add. $taxonomy (string): The taxonomy to which to add the term. $args (array|string): Optional. Array or query string of arguments for inserting a term. Field $alias_of (string): Slug of the term to make this term an alias of. Default empty string. Accepts a term slug. Field $description (string): The term description. Default empty string. Field $parent (int): The id of the parent term. Default 0. Field $slug (string): The term slug to use. Default empty string.
Returns array|WP_Error: An array of the new term data, WP_Error otherwise. Field $term_id (int): The new term ID. Field $term_taxonomy_id (int|string): The new term taxonomy ID. Can be a numeric string.
Term Connections
Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.
Loading term connections…
