Title: Custom Plugin dev insert custom term
Last modified: August 31, 2016

---

# Custom Plugin dev insert custom term

 *  [harrysoup](https://wordpress.org/support/users/harrysoup/)
 * (@harrysoup)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/custom-plugin-dev-insert-custom-term/)
 * Hi,
 * I am building a plugin that requires me to register custom post types and terms.
 * The post type has been registered correctly with:
 *     ```
       if (is_admin()) {
           require_once(plugin_dir_path(__FILE__) . 'classes/aggregator.php');
   
           add_action('init', array('Aggregator', 'init'));
           add_action('init', 'register_post_types');
   
       }
   
       function register_post_types()
       {
           register_post_type('social_post',
               array(
                   'labels' => array(
                       'name' => __('Social Posts'),
                       'singular_name' => __('Social Post')
                   ),
                   'public' => true,
                   'menu_icon' => 'dashicons-admin-users',
                   'taxonomies' => array('area'),
                   'has_archive' => true,
                   'rewrite' => array('slug' => 'social-posts'),
               )
           );
       }
   
       register_taxonomy(
           'social_agg',
           'social_post',
           array(
               'label' => __('Social Aggregator Type'),
               'public' => true,
               'rewrite' => false,
               'hierarchical' => false,
           )
       );
   
       register_taxonomy('platform', array('game', 'post'), array(
           'label' => __('Social Aggregator Type'),
           'public' => true,
           'rewrite' => false,
           'hierarchical' => false,
       ));
       ```
   
 * I also register the taxonomies in this block of code.
 * When inserting the new terms I use the following:
 *     ```
       $types = ["Twitter", "Facebook", "YouTube"];
   
               foreach ($types as $type => $value) {
                   wp_insert_term(
                       $value, // the term
                       'social_agg', // the taxonomy
                       array(
                           'description' => '',
                           'slug' => strtolower($value),
                           'parent' => 0
                       ));
               }
       ```
   
 * Which seems to insert them correctly but always adds in the same amount but with
   IDs in them for values I guess they are aliasing them?
 * Just wondering why they are doing this and if this is avoidable?
 * Looking back at the code is it because the taxonomies aren’t registered in a 
   function on init like the post type?
 * Thanks,
 * Harry

The topic ‘Custom Plugin dev insert custom term’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [harrysoup](https://wordpress.org/support/users/harrysoup/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/custom-plugin-dev-insert-custom-term/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
