dd

wordpress创建分类函数:wp_create_category()


【函数介绍】

wp_create_category() 用于创建新分类,可指定父类

【函数用法】

<?php wp_create_category( $cat_name, $parent ); ?>

【参数】

$cat_name
(string) (必须) 创建的新分类名.
默认: None
$parent
(integer) (可选) 父类ID.
默认: None

【返回值】

(integer)
返回新创建的分类ID,如果创建失败则返回0.

【示例】


<?php
   //创建新分类, 分类名为My category name
   wp_create_category('My category name');
?>

【源代码】

wp_create_category() 位于 wp-admin/includes/taxonomy.php.