title: wordpress, inserting values into custom post type not working
body: <p>When processing the form i want the values to be inserted into the custom post type <code>products</code>.</p>
  
  <p>Here is what i have done so far</p>
  
  <pre><code> $art_title = $_POST['art_title'];
  
      $i = 0;
      foreach($art_title as $value) {
      $art_title = $_POST['art_title'][$i];
      $art_width = $_POST['art_width'][$i];
      $art_height = $_POST['art_height'][$i];
      $art_price = $_POST['art_price'][$i];
      $art_creation_date = $_POST['art_creation_date'][$i];
   $art_upload = $_FILE['art_upload'][$i];
  
         // Add the content of the form to $post as an array
          $new_post = array(
              'post_title'    =&gt; $art_title,
              'post_status'   =&gt; 'draft',    
              'post_type' =&gt; 'products'
          );
          //save the new post
          $pid = wp_insert_post($new_post); 
          $attachment_id = media_handle_upload( 'art_upload', $pid );
  
          if ( is_wp_error( $attachment_id ) ) {
              // There was an error uploading the image.
          } else {
              // The image was uploaded successfully!
          }
  
      $i++;
      }
  </code></pre>
  
  <p>I used media_handle_upload along with the post id but this isn't working.</p>
  
  <p>What i want to know is how do i insert these $_POST values into the custom post type <code>products</code> along with the image as <code>product_image</code>?</p>
  
  <p>The custom post type is the woocommerce <code>products</code>.</p>
  
  <p>Any help greatly appreciated. An example would be great.</p>