Title: create categories with php in a script?
Last modified: August 19, 2016

---

# create categories with php in a script?

 *  [jfrigger](https://wordpress.org/support/users/jfrigger/)
 * (@jfrigger)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/create-categories-with-php-in-a-script/)
 * Hello,
 * i’d like to create posts from an xml feed and want to multiple main and subcategories
   to each post. with the function wp_insert_post it is only possible to add categories
   by their id.
 * my question: is it possible to create a category (if it doesn’t exist) and get
   back the ID of the category in a variable?
 * thanks in advance!
 * Greetings from germany.

The topic ‘create categories with php in a script?’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jfrigger](https://wordpress.org/support/users/jfrigger/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/create-categories-with-php-in-a-script/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
