wp_update_term

Sponsored Link

指定された引数に基づいてタームを更新します。

Sponsored Link

Update term based on arguments provided.

wp_update_termのファンクションタグ使用方法

<?php wp_update_term( $term_id, $taxonomy, $args )  ?>

wp_update_termのパラメーター

$term_id

(int) (required) タームのID
デフォルト:なし

(int) (required) The ID of the term.
Default: None

$taxonomy

(string) (required)オブジェクトにタームを関連する文脈。
デフォルト:なし

(string) (required) The context in which to relate the term to the object.
Default: None

$args

(array) (optional) タームのフィールド値をオーバーライドする。
デフォルト:なし

(array) (optional) Overwrite term field values.
Default: None

戻り値

(array|WP_Error)

タームIDとタクソノミータームID(配列内に)を返します。或いは、WP_Errorオブジェクト。

(array|WP_Error)
Returns Term ID and Taxonomy Term ID (in an array). Or an WP_Error object.

フランス語で’Uncategorized’カテゴリーの名前を変更します。

<?php
wp_update_term(1, 'category', array(
  'name' => 'Non Catégorisé',
  'slug' => 'non-categorise'
));
?>

注意

$argsは無差別に同じフィールド名を持つすべての値をオーバーライドします。注意は、更新する必要がある重要な情報や更新が失敗しないように上書きしないように注意しなければなりません。

デフォルトは既に$argsが定義されていない場合、’alias_of’, ‘description’, ‘parent’, と ‘slug’が設定します。

‘alias_of’はタームグループを作成し、既にそれが存在していない場合、$termの為に更新します。

$args内の’slug’の引数がミスしている場合、$args内には’name’が使用されます。’slug’が設定してそれがユニークでない場合、WP_Errorが戻される事にも注意すべきです。あなたが任意のslugを渡さない場合は、ユニークの1つが自動的に作成されます。

何が$args内にオーバーライドすることができるため、ターム体型は含めることができ、タームキーから避けることをチェックします。

タームオブジェクトに$argsを許可します:

The $args will indiscriminately override all values with the same field name. Care must be taken to not override important information need to update or update will fail (or perhaps create a new term, neither would be acceptable).

Defaults will set ‘alias_of’, ‘description’, ‘parent’, and ‘slug’ if not defined in $args already.

‘alias_of’ will create a term group, if it doesn’t already exist, and update it for the $term.

If the ‘slug’ argument in $args is missing, then the ‘name’ in $args will be used. It should also be noted that if you set ‘slug’ and it isn’t unique then a WP_Error will be passed back. If you don’t pass any slug, then a unique one will be created for you.

For what can be overrode in $args, check the term scheme can contain and stay away from the term keys.

Allowed $args for the term object:

  • term_id
  • name
  • slug
  • term_group
  • term_taxonomy_id
  • taxonomy
  • description
  • parent
  • count

変更ログ

Since: 2.3.0

ソースファイル

wp_update_term()は、wp-includes/taxonomy.php内に位置しています。

wp_update_term() is located in wp-includes/taxonomy.php.

関連ファンクションタグ

wp_insert_term

Sponsored Link