Summery Summery
Add a new category to the database if it does not already exist.
Syntax Syntax
Parameters Parameters
- $cat_name
-
(Required)
- $parent
-
(Required)
Return Return
(int|WP_Error)
Source Source
File: wp-admin/includes/taxonomy.php
function wp_create_category( $cat_name, $parent = 0 ) { $id = category_exists( $cat_name, $parent ); if ( $id ) { return $id; } return wp_insert_category( array( 'cat_name' => $cat_name, 'category_parent' => $parent, ) ); }
Advertisement
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |