Core Function
View Source on Trac ↗ wp_set_object_terms()
wp_set_object_terms( mixed $object_id, mixed $terms, mixed $taxonomy, mixed $append = false ) Creates term and taxonomy relationships.
Parameters 3 required
| Name / Type | Description |
|---|---|
| $object_id int | The object to relate to. Required |
| mixed | (string | int | array) $terms A single term slug, single term ID, or array of either term slugs or IDs. Will replace all existing related terms in this taxonomy. Passing an empty array will remove all related terms. Required |
| $taxonomy string | The context in which to relate the term to the object. Required |
| $append bool | Optional. If false will delete difference of terms. Default false. |
Return Value
((array)
| WP_Error) Term taxonomy IDs of the affected terms or WP_Error on failure.
Function Information
Since Version
2.3.0
Source File
wp-includes/taxonomy.php
Advertisement