wp_update_term()更新一个分类的信息

目录

描述

Update term based on arguments provided.

wp_update_term() 描述

用法

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

wp_update_term() 用法

参数

$term_id

(int) (必填) The ID of the term.

默认值: None

$taxonomy

(string) (必填) The context in which to relate the term to the object.

默认值: None

$args

(array) (可选) Overwrite term field values.

默认值: None

wp_update_term() 参数

返回值

(array|WP_Error) 

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

wp_update_term() 返回值

注意

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

wp_update_term() 注意

历史

添加于 版本: 2.3.0

wp_update_term() 历史

源文件

wp_update_term() 函数的代码位于 wp-includes/taxonomy.php.

wp_update_term() 源文件

相关