wp_add_object_terms() - WordPress 函数参考中文文档

返回介绍

wp_add_object_terms()

发布于 2017-09-11 字数1817 浏览 747 评论 0

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

Add term(s) associated with a given object.


描述


参数

$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.


返回值

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


源代码

File: wp-includes/taxonomy.php

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

更新日志

Version 描述
3.6.0 Introduced.

相关函数

Uses

  • wp-includes/taxonomy.php:
    wp_set_object_terms()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Set categories for an attachment

    wp_add_object_terms( $attachment_id, 'Uncategorized', 'category' );

上一篇:wp_add_inline_style()

下一篇:wp_add_post_tags()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!