Usage
<?php wp_create_category( $cat_name, $parent ); ?>
Parameters
- $cat_name
- (string) (required) Name for the new category.
- Default: None
- $parent
- (integer) (optional) Category ID of the parent category.
- Default: None
Return Values
- (integer)
- 0 on failure, category id on success.
Examples
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);
Hiç yorum yok:
Yorum Gönder