wp_insert_category()通过代码创建一个分类

目录

描述

Inserts a new category into the taxonomy system.

wp_insert_category() 描述

用法

<?php wp_insert_category$catarr$wp_error ); ?>

wp_insert_category() 用法

参数

$catarr

(array) (必填) Category information.

默认值: None

$catarr is checked against an array with the following default values:

$catarr may contain additional values, but it is recommended that you provide at least the minimum of those defined in $cat_defaults. Note that category_parent is a category ID.

$wp_error

(boolean) (可选) Whether to return a WP_Error or a boolean. Boolean by default.

默认值: false

wp_insert_category() 参数

返回值

(boolean | WP_Error | int) 

True on success and false on failure OR a WP_Error on failure and the Category ID of the new category on true.

wp_insert_category() 返回值

示例

To insert a new category use:

wp_insert_category() 示例

注意

  • Not all possible members of the $catarr array are listed here.
  • See wp_create_category() for a simpler version which takes just a string instead of an array.

wp_insert_category() 注意

源文件

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

wp_insert_category() 源文件