wp_add_object_terms() WordPress Function

The wp_add_object_terms() function is used to add terms to an object. This function can be used to add terms to posts, pages, attachments, and custom post types. This function accepts four parameters: the object ID, the taxonomy slug, an array of terms, and a append flag.

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

Adds term(s) associated with a given object.


Parameters

$object_id

(int)(Required)The ID of the object to which the terms will be added.

$terms

(string|int|array)(Required)The slug(s) or ID(s) of the term(s) to add.

$taxonomy

(array|string)(Required)Taxonomy name.


Top ↑

Return

(array|WP_Error) Term taxonomy IDs of the affected terms.


Top ↑

Source

File: wp-includes/taxonomy.php

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


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More