views:

37

answers:

1

Using a built in wordpress function (if available) how do I create a new category in wordpress if it doesn't exist.

I'm using wp_insert_post to insert posts, but I want to be able to do custom categories.

Thanks

-Brad

A: 

You can use wp_create_categories('catname') and to get_cat_ID('catname') to get the id.

wp_create_categories

get_cat_ID

Brad