Title: wp_create/wp_insert_category Undefined Error
Last modified: August 19, 2016

---

# wp_create/wp_insert_category Undefined Error

 *  Resolved [WebTechGlobal](https://wordpress.org/support/users/webtechglobal/)
 * (@webtechglobal)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/wp_createwp_insert_category-undefined-error/)
 * Hey all,
 * Greatly appreciate help with this one I just don’t get it.
 * wp_create_category or wp_insert_category on my CSV 2 POST plugin works sometimes
   but not others! I’m currently using it on [http://www.1book2books.co.uk](http://www.1book2books.co.uk)
   and it created 3 category automatically.
 * 250 hits later it’s now telling me…
 * Fatal error: Call to undefined function: wp_insert_category()
 * I don’t get this at all I can’t even begin to guess why it happens. It’s not 
   the first time either and when it happened 2 weeks ago I forgot about it because
   it went away. So there must be something with WordPress that loads taxonomy sometimes
   but not others.
 * My plugin action is in the footer if that helps.
 * Thanks and there is £2.50 paypal in it for someone who provides a true fix.
 * Ryan

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [jikoyster](https://wordpress.org/support/users/jikoyster/)
 * (@jikoyster)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/wp_createwp_insert_category-undefined-error/#post-1182086)
 * I had the same problem and find the answer at taxonomy.php in wp-includes directory.
 * use wp_insert_term instead
    here’s the code:
 *     ```
       if(!is_term($term, $taxonomy)){
         wp_insert_term($term, $taxonomy, $args);
       }
       ```
   
 * where $term is the category name
    and $taxonomy is either ‘tag’ or ‘category’
   $args is an array fields for the category same with wp_insert_category
 *  [kiranthomman](https://wordpress.org/support/users/kiranthomman/)
 * (@kiranthomman)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wp_createwp_insert_category-undefined-error/#post-1182102)
 * Thanks jikoyster I too had a problem with wp_insert_category inside functions
   it seemed to work for some calls but refused to work during others. Finally I
   tried what you said and it works like a charm
 *  [zsiswick](https://wordpress.org/support/users/zsiswick/)
 * (@zsiswick)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wp_createwp_insert_category-undefined-error/#post-1182107)
 * Yeah, I was totally beating my head against the wall until I found this post.
   Thank you jikoyster!
 *  [ChefGaby](https://wordpress.org/support/users/glamourgaby/)
 * (@glamourgaby)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/wp_createwp_insert_category-undefined-error/#post-1182112)
 * When you use wp_insert_category you would add “category_description” and “category_parent”
   to the array. For this function the values are “description” and “parent”.
 * Here is a complete example of the usage:
 *     ```
       $arg = array('description' => "my description", 'parent' => "cat_ID");
       $new_cat_id = wp_insert_term("cat name", "category", $arg);
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘wp_create/wp_insert_category Undefined Error’ is closed to new replies.

 * 4 replies
 * 5 participants
 * Last reply from: [ChefGaby](https://wordpress.org/support/users/glamourgaby/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/wp_createwp_insert_category-undefined-error/#post-1182112)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
