- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/wp add object terms
提供: WordPress Codex 日本語版
Add term(s) associated with a given object. Wrapper for wp_set_object_terms().
パラメータ
- $object_id
- (int) (必須) The ID of the object to which the terms will be added.
- 初期値: なし
- $terms
- (mixed) (必須) The slug(s) or ID(s) of the term(s) to add. Accepts array, int or string.
- 初期値: なし
- $taxonomy
- (mixed) (必須) The taxonomy name. Accepts array or string.
- 初期値: なし
戻り値
- (mixed)
- An array of affected term IDs, WP_Error otherwise.
使用法
<?php wp_add_object_terms( $id, $terms, $taxonomy ); ?> %%%
使用例
Set categories for an attachment.
wp_add_object_terms( $attachment_id, 'Uncategorized', 'category' );
改訂履歴
- 3.6.0 にて導入されました。
ソースファイル
wp_add_object_terms() is located in wp-includes/taxonomy.php
.
関連項目
最新英語版: WordPress Codex » Function Reference/wp add object terms (最新版との差分)