wp_create_category()
Add a new category to the database if it does not already exist.
Uses: wp_insert_category()
No Hooks.
Return
Int|WP_Error
.
Usage
wp_create_category( $cat_name, $parent );
- $cat_name(int|string) (required)
- -
- $parent(int)
- -
Changelog
Since 2.0.0 | Introduced. |
Code of wp_create_category() wp create category WP 5.9.3
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, ) ); }