W3cubDocs

/WordPress

wp_add_object_terms( int $object_id, string|int|array $terms, array|string $taxonomy ): array|WP_Error

Adds term(s) associated with a given object.

Parameters

$object_idintrequired
The ID of the object to which the terms will be added.
$termsstring|int|arrayrequired
The slug(s) or ID(s) of the term(s) to add.
$taxonomyarray|stringrequired
Taxonomy name.

Return

array|WP_Error Term taxonomy IDs of the affected terms.

Source

function wp_add_object_terms( $object_id, $terms, $taxonomy ) {
	return wp_set_object_terms( $object_id, $terms, $taxonomy, true );
}

Changelog

Version Description
3.6.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_add_object_terms