wp_create_category()
wp_create_category( int|string $cat_name, int $parent )…
wp_create_category( int|string $cat_name, int $parent )
如果新类别不存在,请将其添加到数据库中。
Add a new category to the database if it does not already exist.
如果新类别不存在,请将其添加到数据库中。
Add a new category to the database if it does not already exist.
目录锚点:#参数#源码#笔记
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $cat_name | (int | string) | $家长 |
| (int) | (Required) |
源码(Source)
/**
* Add a new category to the database if it does not already exist.
*
* @since 2.0.0
*
* @param int|string $cat_name
* @param int $parent
* @return int|WP_Error
*/
function wp_create_category( $cat_name, $parent = 0 ) {
if ( $id = category_exists($cat_name, $parent) )
return $id;
return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.0.0 | wp-admin/includes/taxonomy.php | 13 | 14 |
笔记(Notes)
示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。


还没有任何评论,赶紧来占个楼吧!