Function: wp_add_object_terms

wp_add_object_terms( integer $object_id, string | integer | array $terms, array | string $taxonomy )

Add term(s) associated with a given object.

Shortcut: waot

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.


Name Type(s) Default Value Description
$object_id integer

The ID of the object to which the terms will be added.

$terms string | integer | array

The slug(s) or ID(s) of the term(s) to add.

$taxonomy array | string

Taxonomy name.


array | WP_Error

Term taxonomy IDs of the affected terms.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.