Title: Batch Category Add
Last modified: August 19, 2016

---

# Batch Category Add

 *  [ashley3ee](https://wordpress.org/support/users/ashley3ee/)
 * (@ashley3ee)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/batch-category-add/)
 * Does anyone know of a way to add multiple categories at once instead of one at
   a time? (maybe by import or a plugin)
 * I created a parent category and now I want to create about 100 categories under
   that.
 * Thanks!

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/batch-category-add/#post-1294037)
 * Could try this:
 *     ```
       <?php
       //import categories from csv
       //sample data for $import_file category,category parent,slug,description
       //Parent categories must be in file before child categories
       //
       //"county1",""
       //"county2",""
       //"city1","county1"
       //"city2","county2"
       //"city3","county1"
       //"county3",""
       //"County Cork","","county cork","county cork descripiton of this cat"
       //"County Morefields","","","This is description of county morefields"
   
       require_once(ABSPATH . "wp-admin/includes/admin.php");
       $import_file = TEMPLATEPATH . '/cat.txt';
       $import = array();
       $fh = fopen($import_file,'r');
       while($t = fgetcsv($fh)) {
           $import[] = $t;
       }
   
       foreach ($import as $importcat) {
         $numfields=count($importcat);
         $cat_ID = get_cat_ID($importcat[0]);
         $cat_name = $importcat[0];
         $category_parent = get_cat_ID($importcat[1]);
   
         if ($numfields > 2)
           $category_nicename = sanitize_title($importcat[2]);
   
         if ($numfields > 3)
           $category_description = $importcat[3];
   
         $args = compact('cat_ID', 'cat_name', 'category_description', 'category_nicename', 'category_parent');
         wp_insert_category($args);
       }
       ?>
       ```
   
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/batch-category-add/#post-1294111)
 * Or this:
    [https://wpsecurity.net/http//wpsecurity.net/download/bulk-category-importer.zip](https://wpsecurity.net/http//wpsecurity.net/download/bulk-category-importer.zip)

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

The topic ‘Batch Category Add’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/batch-category-add/#post-1294111)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
