title: Custom field to category
body: <p>I use to see this script to auto fields to a category</p>
  
  <pre><code>function wpse_248054(){
  
      $custom_field_name = 'Genre';
  
      $posts = new WP_Query(
          array(
              'posts_per_page' =&gt; -1,
              'post_type'=&gt; 'post',
          )   
      );
  
      foreach($posts-&gt;posts as $post){
  
          $meta = get_post_meta($post-&gt;ID, 'Genre', true);
  
          if(! empty( $meta )){
              $term_id = wp_create_category($meta, 3); // 2nd argument, parent id (optional)
  
              $new_post_cat = wp_set_post_terms( $post-&gt;ID, $term_id, 'category', true );
  
          }
      }
  }
  
  add_action('admin_init', 'wpse_248054');
  </code></pre>
  
  <p>The meta key is <code>Genre</code>.  </p>
  
  <p>But contains comma separator (example: Short, Western, Drama)  </p>
  
  <p>And this script creates a category <code>Short, Western, Drama</code> altogether, who can I adjust this?</p>