Languages: English • Italiano • 日本語 (Add your language)
This function adds a "simple" category by specifying a category name and (optionally) a category parent. This is a shorter version of wp_insert_category.
<?php wp_create_category( $cat_name, $parent ); ?>
In order to create a simple category use:
wp_create_category('My category name');
To create a category that is a child of Uncategorized (or whatever category has the ID 0), use:
wp_create_category('Child of Uncategorized', 0);
To get id of category created and put value in variable:
$id = wp_create_category('Child of Uncategorized', 0);
wp_create_category() is located in wp-admin/includes/taxonomy.php
.